﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

using H2.NET.Controls;
using H2.NET.Business;
using H2.NET.Data.Common;

namespace H2.NET.Web.Pages
{
    public partial class PKCMD : TaskPage
    {
        #region 属性 Public
        private bool IsLoaded
        {
            get
            {
                return ViewState["IsLoaded"] == null ? false : (bool)ViewState["IsLoaded"];
            }
            set { ViewState["IsLoaded"] = value; }
        }
        #endregion

        #region 事件 Page_Load(页面加载)
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                INFO.Text = string.Format("<br/>表单正在被同事“{0}”抢占处理，拒绝提交！", RobUser);
                INFO.Visible = IsOverFlow;

                bool flg = (TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit) ? true : false;
                //InitDropDownList();

                #region 发起步骤
                if (TaskAPI.IsInitiate)
                {
                    VD.Checked = true;
                }
                if ((TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit))
                {
                    InitDropDownList();
                    SetColor();
                }
                #endregion

                #region 审批环节
                if(!TaskAPI.IsInitiate)
                {
                    #region 加载数据并显示 
                    TW_cmd_Customer_PKG cmd = (TW_cmd_Customer_PKG.process == TaskAPI.Process & TW_cmd_Customer_PKG.incident == TaskAPI.Incident).ListFirst<TW_cmd_Customer_PKG>();
                    if (cmd != null)
                    {
                        //SetColor();
                        ApplicationNo.Text                  = cmd.ApplicationNo;
                        Actions.SelectedValue               = cmd.Actions;
                        DrpPriority.SelectedValue = cmd.DrpPriority;
                        DMO_DrpPriority.SelectedValue = cmd.DMO_DrpPriority;
                        
                        SetColor();
                        VD.Checked                          = cmd.VD_Checked == "1";
                        SA2.Checked                         = cmd.SA2_Checked == "1";



                        #region Sold to
                        BA_Existed_Sold_To_Code.Text = cmd.BA_Existed_Sold_To_Code;
                        BA_BPCS_Code.Text = cmd.BA_BPCS_Code;
                        BA_Customer_Name_In_ZH.Text = cmd.BA_Customer_Name_In_ZH;
                        BA_Search_Term_1.Text = cmd.BA_Search_Term_1;
                        BA_Search_Term_2.Text = cmd.BA_Search_Term_2;
                        BA_Hierarchy_1.Text = cmd.BA_Hierarchy_1;
                        BA_Hierarchy_2.Text = cmd.BA_Hierarchy_2;
                        BA_Sales_Employee_Code.Text = cmd.BA_Sales_Employee_Code;
                        BA_Existed_Sold_To_Code_City.Text = cmd.BA_Existed_Sold_To_Code_City;
                        BA_Sales_Employee.Text=cmd.BA_Sales_Employee;
                        BA_Street4.Text = cmd.BA_Street4;
                        BA_Existed_Sold_To_Code_Address.Text = cmd.BA_Existed_Sold_To_Code_Address;
                        BA_Existed_Sold_To_Code_Contact_Preson.Text = cmd.BA_Existed_Sold_To_Code_Contact_Preson;
                        BA_Existed_Sold_To_Code_Tel.Text = cmd.BA_Existed_Sold_To_Code_Tel;
                        BA_Post_Code.Text = cmd.BA_Post_Code;
                        BA_Email.Text = cmd.BA_Email;
                        BA_Fax.Text = cmd.BA_Fax;
                        Internat_Name.Text = cmd.Internat_Name;
                        Internat_Seach_Term.Text = cmd.Internat_Seach_Term;
                        Internat_Language.Text = cmd.Internat_Language;
                        Internat_Address.Text = cmd.Internat_Address;
                        Internat_City.Text = cmd.Internat_City;
                        Internat_Tel.Text = cmd.Internat_Tel;
                        Internat_Mobile.Text = cmd.Internat_Mobile;
                        Internat_Mail.Text = cmd.Internat_Mail;
                        Internat_Fax.Text = cmd.Internat_Fax;
                        BA_Existed_Payer_To_Code.Text = cmd.BA_Existed_Payer_To_Code;
                        BA_Bill_Name1.Text = cmd.BA_Bill_Name1;
                        BA_Bill_Search_Term1.Text = cmd.BA_Bill_Search_Term1;
                        BA_Bill_Search_Term2.Text = cmd.BA_Bill_Search_Term2;
                        BA_Bill_City.Text = cmd.BA_Bill_City;
                        BA_Bill_County_Code.Text = cmd.BA_Bill_County_Code;
                        BA_Bill_Street4.Text = cmd.BA_Bill_Street4;
                        BA_Bill_Address.Text = cmd.BA_Bill_Address;
                        BA_Bill_Contact_Person.Text = cmd.BA_Bill_Contact_Person;
                        BA_Bill_Tel.Text = cmd.BA_Bill_Tel;
                        BA_Bill_Postal_Code.Text = cmd.BA_Bill_Postal_Code;
                        BA_Bill_Mail.Text = cmd.BA_Bill_Mail;
                        BA_Bill_Fax.Text = cmd.BA_Bill_Fax;
                        BA_Existed_Code.Text = cmd.BA_Existed_Code;
                        BA_Old_BPCS_Indirect.Text = cmd.BA_Old_BPCS_Indirect;
                        BA_Indirect_Name1.Text = cmd.BA_Indirect_Name1;
                        BA_Indirect_Name2.Text = cmd.BA_Indirect_Name2;
                        BA_Indirect_Search_Term1.Text = cmd.BA_Indirect_Search_Term1;
                        BA_Indirect_Search_Term2.Text = cmd.BA_Indirect_Search_Term2;
                        BA_Indirect_City.Text = cmd.BA_Indirect_City;
                        BA_Indirect_Street4.Text = cmd.BA_Indirect_Street4;
                        BA_Indirect_Address.Text = cmd.BA_Indirect_Address;
                        BA_Indirect_Person.Text = cmd.BA_Indirect_Person;
                        BA_Indirect_Tel.Text = cmd.BA_Indirect_Tel;
                        BA_Indirect_Postal_Code.Text = cmd.BA_Indirect_Postal_Code;
                        BA_Indirect_Mail.Text = cmd.BA_Indirect_Mail;
                        BA_Indirect_Fax.Text = cmd.BA_Indirect_Fax;
                        //BA_Indirect_Transportation_Zone.Text = cmd.BA_Indirect_Transportation_Zone;
                        //BA_Transportation_Zone.Text = cmd.BA_Transportation_Zone;
                        BA_Industry_Code2.Text = cmd.BA_Industry_Code2;
                        BA_County_Code.Text = cmd.BA_County_Code;
                        BA_Tax_Number2.Text = cmd.BA_Tax_Number2;
                        BA_Bank_Key.Text = cmd.BA_Bank_Key;
                        BA_Bank_Name.Text = cmd.BA_Bank_Name;
                        BA_Account.Text = cmd.BA_Account;
                        BA_Acct_Holder.Text = cmd.BA_Acct_Holder;
                        CO_Company.Text = cmd.CO_Company;
                        CO_Dunn_Procedure.Text = cmd.CO_Dunn_Procedure;
                        CO_Sort_Key.Text = cmd.CO_Sort_Key;
                        CO_BPCS.Text = cmd.CO_BPCS;
                        CO_Cash_Mgmt.Text = cmd.CO_Cash_Mgmt;
                        SA_Max_Partial_Deliveries_1.Text = cmd.SA_Max_Partial_Deliveries_1;
                        CO_Bank_Statement.Text = cmd.CO_Bank_Statement;
                        SA_Sales_Org.Text = cmd.SA_Sales_Org;
                        SA_Order_Combination.Text = cmd.SA_Order_Combination;
                        SA_Partial_Delivery_Per_Item.Text = cmd.SA_Partial_Delivery_Per_Item;
                        SA_Tax_Classification.Text = cmd.SA_Tax_Classification;
                        SA_Itcoterms2.Text = cmd.SA_Itcoterms2;
                        SA_Departing_Country.Text = cmd.SA_Departing_Country;
                        SA_Customer_Group_3.Text = cmd.SA_Customer_Group_3;
                        SA_Partner_Function.Text = cmd.SA_Partner_Function;
                        SA_Partner_Number.Text = cmd.SA_Partner_Number;
                        SA_Customer_Description.Text = cmd.SA_Customer_Description;
                        SA_Sales_Code.Text = cmd.SA_Sales_Code;
                        Text_Internal.Text = cmd.Text_Internal;
                        Text_Shipping.Text = cmd.Text_Shipping;
                        Text_Pay.Text = cmd.Text_Pay;
                        Text_External.Text = cmd.Text_External;
                        Attributes8.Text = cmd.Attributes8;
                        Attributes9.Text = cmd.Attributes9;
                        SA_Terms_Of_Payment.Text = cmd.SA_Terms_Of_Payment;
                        SA_Distribution_Channel.Text = cmd.SA_Distribution_Channel;
                        BA_Industry_Code3.Text = cmd.BA_Industry_Code3;
                        SA_Delivering_Plant.Text = cmd.SA_Delivering_Plant;
                        BA_Industry.Text = cmd.BA_Industry;

                        SetDropDownListValue(SA_Currency, cmd.SA_Currency);
                        SetDropDownListValue(BA_Indirect_Transportation_Zone, cmd.BA_Indirect_Transportation_Zone);
                        SetDropDownListValue(BA_Transportation_Zone, cmd.BA_Transportation_Zone);
                        SetDropDownListValue(BA_Type, cmd.BA_Type);
                        SetDropDownListValue(BA_Account_Group, cmd.BA_Account_Group);
                        SetDropDownListValue(BA_Country, cmd.BA_Country);
                        SetDropDownListValue(BA_Region, cmd.BA_Region);
                        SetDropDownListValue(BA_Language, cmd.BA_Language);
                        SetDropDownListValue(BA_Default_BillTo, cmd.BA_Default_BillTo);
                        SetDropDownListValue(BA_Bill_City_Code, cmd.BA_Bill_City_Code);
                        SetDropDownListValue(BA_Default_Indirect, cmd.BA_Default_Indirect);
                        //SetDropDownListValue(BA_Industry, cmd.BA_Industry);
                        SetDropDownListValue(BA_Bank_Country, cmd.BA_Bank_Country);
                        SetDropDownListValue(CO_Recon_Account, cmd.CO_Recon_Account);
                        SetDropDownListValue(CO_Payment_Terms, cmd.CO_Payment_Terms);
                        SetDropDownListValue(CO_Payment_Methods, cmd.CO_Payment_Methods);
                        SetDropDownListValue(SA_Sales_Office, cmd.SA_Sales_Office);
                        SetDropDownListValue(SA_Delivery_Priority, cmd.SA_Delivery_Priority);
                        SetDropDownListValue(SA_Shipping_Condition, cmd.SA_Shipping_Condition);
                        SetDropDownListValue(BA_Cust_Pric, cmd.BA_Cust_Pric);
                        SetDropDownListValue(SA_Acct_Assgmt_Group, cmd.SA_Acct_Assgmt_Group);
                        SetDropDownListValue(SA_Itcoterms, cmd.SA_Itcoterms);
                        SetDropDownListValue(Attributes1, cmd.Attributes1);
                        SetDropDownListValue(Attributes2, cmd.Attributes2);
                        SetDropDownListValue(Attributes3, cmd.Attributes3);
                        SetDropDownListValue(Attributes4, cmd.Attributes4);
                        SetDropDownListValue(Attributes5, cmd.Attributes5);;
                        SetDropDownListValue(BA_City_Code, cmd.BA_City_Code);
                        SetDropDownListValue(BA_APO_Group, cmd.BA_APO_Group);
                        //SetDropDownListValue(Attributes6, cmd.Attributes6);
                        SetDropDownListValue(Attributes7, cmd.Attributes7);
                        SetDropDownListValue(BA_Industry1, cmd.BA_Industry1);
                        SetDropDownListValue(BA_Instruction_Key, cmd.BA_Instruction_Key);

                        SA_Customer_Division_K4.Checked = cmd.SA_Customer_Division_K4 == "1";
                        SA_Customer_Division_K5.Checked = cmd.SA_Customer_Division_K5 == "1";
                       
                        SA_Switch_Off_Rounding.Checked = cmd.SA_Switch_Off_Rounding == "1";
                        SA_Relevant_For_POD.Checked = cmd.SA_Relevant_For_POD == "1";
                        SA_Rebate.Checked = cmd.SA_Rebate == "1";
                        SA_Price_Determin.Checked = cmd.SA_Price_Determin == "1";
                        SA_Complete_Delivery_Reqd_By_Law.Checked = cmd.SA_Complete_Delivery_Reqd_By_Law == "1";
                        CO_Payment_History_Record.Checked = cmd.CO_Payment_History_Record == "1";
                        #endregion


                        #region Rebeat
                        RE_BA_Existed_Sold_To_Code.Text = cmd.RE_BA_Existed_Sold_To_Code;
                        RE_BA_Account_Group.Text = cmd.RE_BA_Account_Group;
                        RE_BA_BPCS_Code.Text = cmd.RE_BA_BPCS_Code;
                        RE_BA_Customer_Name_In_ZH.Text = cmd.RE_BA_Customer_Name_In_ZH;
                        RE_BA_Search_Term_1.Text = cmd.RE_BA_Search_Term_1;
                        RE_BA_Search_Term_2.Text = cmd.RE_BA_Search_Term_2;
                        RE_BA_Hierarchy_1.Text = cmd.RE_BA_Hierarchy_1;
                        RE_BA_Hierarchy_2.Text = cmd.RE_BA_Hierarchy_2;
                        RE_BA_Sales_Employee_Code.Text = cmd.RE_BA_Sales_Employee_Code;
                        RE_BA_Sales_Employee.Text=cmd.RE_BA_Sales_Employee;
                        
                        RE_BA_Existed_Sold_To_Code_City.Text = cmd.RE_BA_Existed_Sold_To_Code_City;
                        RE_BA_SoldTo_Code.Text = cmd.RE_BA_SoldTo_Code;
                        RE_BA_Street4.Text = cmd.RE_BA_Street4;
                        RE_BA_Existed_Sold_To_Code_Address.Text = cmd.RE_BA_Existed_Sold_To_Code_Address;
                        RE_BA_Existed_Sold_To_Code_Contact_Preson.Text = cmd.RE_BA_Existed_Sold_To_Code_Contact_Preson;
                        RE_BA_Existed_Sold_To_Code_Tel.Text = cmd.RE_BA_Existed_Sold_To_Code_Tel;
                        RE_BA_Post_Code.Text = cmd.RE_BA_Post_Code;
                        RE_BA_Email.Text = cmd.RE_BA_Email;
                        RE_BA_Fax.Text = cmd.RE_BA_Fax;
                        //RE_BA_Transportation_Zone.Text = cmd.RE_BA_Transportation_Zone;
                        RE_BA_County_Code.Text = cmd.RE_BA_County_Code;
                        RE_BA_Tax_Number2.Text = cmd.RE_BA_Tax_Number2;
                        RE_BA_Bank_Key.Text = cmd.RE_BA_Bank_Key;
                        RE_BA_Bank_Name.Text = cmd.RE_BA_Bank_Name;
                        RE_CO_Dunn_Procedure.Text = cmd.RE_CO_Dunn_Procedure;
                        RE_BA_Industry_Code2.Text = cmd.RE_BA_Industry_Code2;
                        RE_BA_Account.Text = cmd.RE_BA_Account;
                        RE_BA_Acct_Holder.Text = cmd.RE_BA_Acct_Holder;
                        RE_CO_Company.Text = cmd.RE_CO_Company;
                        RE_CO_Sort_Key.Text = cmd.RE_CO_Sort_Key;
                        RE_CO_BPCS.Text = cmd.RE_CO_BPCS;
                        RE_CO_Cash_Mgmt.Text = cmd.RE_CO_Cash_Mgmt;
                        RE_CO_Bank_Statement.Text = cmd.RE_CO_Bank_Statement;
                        RE_SA_Sales_Org.Text = cmd.RE_SA_Sales_Org;
                        RE_SA_Partial_Delivery_Per_Item.Text = cmd.RE_SA_Partial_Delivery_Per_Item;
                        RE_SA_Max_Partial_Deliveries_1.Text = cmd.RE_SA_Max_Partial_Deliveries_1;
                        RE_SA_Order_Combination.Text = cmd.RE_SA_Order_Combination;
                        RE_SA_Tax_Classification.Text = cmd.RE_SA_Tax_Classification;
                        RE_SA_Itcoterms2.Text = cmd.RE_SA_Itcoterms2;
                        RE_SA_Departing_Country.Text = cmd.RE_SA_Departing_Country;
                        RE_SA_Terms_Of_Payment.Text = cmd.RE_SA_Terms_Of_Payment;
                        RE_SA_Customer_Group_3.Text = cmd.RE_SA_Customer_Group_3;
                        RE_SA_Partner_Function.Text = cmd.RE_SA_Partner_Function;
                        RE_SA_Partner_Number.Text = cmd.RE_SA_Partner_Number;
                        RE_SA_Customer_Description.Text = cmd.RE_SA_Customer_Description;
                        RE_SA_Sales_Code.Text = cmd.RE_SA_Sales_Code;
                        RE_Text_Internal.Text = cmd.RE_Text_Internal;
                        RE_Text_Shipping.Text = cmd.RE_Text_Shipping;
                        RE_Text_Pay.Text = cmd.RE_Text_Pay;
                        RE_Text_External.Text = cmd.RE_Text_External;
                        RE_BA_Industry_Code3.Text = cmd.RE_BA_Industry_Code3;
                        //RE_Attributes6.Text = cmd.RE_Attributes6;
                        RE_Attributes7.Text = cmd.RE_Attributes7;
                        RE_Attributes8.Text = cmd.RE_Attributes8;
                        RE_Attributes9.Text = cmd.RE_Attributes9;
                        RE_SA_Distribution_Channel.Text = cmd.RE_SA_Distribution_Channel;
                        RE_SA_Delivering_Plant.Text = cmd.RE_SA_Delivering_Plant;
                        RE_BA_Industry.Text = cmd.RE_BA_Industry;

                        SetDropDownListValue(RE_SA_Currency, cmd.RE_SA_Currency);
                        SetDropDownListValue(RE_BA_Country, cmd.RE_BA_Country);
                        SetDropDownListValue(RE_BA_Transportation_Zone, cmd.RE_BA_Transportation_Zone);
                        SetDropDownListValue(RE_BA_Type, cmd.RE_BA_Type);
                        SetDropDownListValue(RE_BA_Region, cmd.RE_BA_Region);
                        SetDropDownListValue(RE_BA_Language, cmd.RE_BA_Language);
                        //SetDropDownListValue(RE_BA_Industry, cmd.RE_BA_Industry);
                        SetDropDownListValue(RE_BA_Industry1, cmd.RE_BA_Industry1);
                        SetDropDownListValue(RE_BA_Instruction_Key, cmd.RE_BA_Instruction_Key);
                        SetDropDownListValue(RE_BA_APO_Group, cmd.RE_BA_APO_Group);
                        SetDropDownListValue(RE_BA_City_Code, cmd.RE_BA_City_Code);
                        SetDropDownListValue(RE_BA_Bank_Country, cmd.RE_BA_Bank_Country);
                        SetDropDownListValue(RE_CO_Recon_Account, cmd.RE_CO_Recon_Account);
                        SetDropDownListValue(RE_CO_Payment_Terms, cmd.RE_CO_Payment_Terms);
                        SetDropDownListValue(RE_CO_Payment_Methods, cmd.RE_CO_Payment_Methods);
                        SetDropDownListValue(RE_SA_Sales_Office, cmd.RE_SA_Sales_Office);
                        SetDropDownListValue(RE_SA_Delivery_Priority, cmd.RE_SA_Delivery_Priority);
                        SetDropDownListValue(RE_SA_Shipping_Condition, cmd.RE_SA_Shipping_Condition);
                        SetDropDownListValue(RE_BA_Cust_Pric, cmd.RE_BA_Cust_Pric);
                        SetDropDownListValue(RE_SA_Acct_Assgmt_Group, cmd.RE_SA_Acct_Assgmt_Group);
                        SetDropDownListValue(RE_SA_Itcoterms, cmd.RE_SA_Itcoterms);
                        SetDropDownListValue(RE_Attributes1, cmd.RE_Attributes1);
                        SetDropDownListValue(RE_Attributes2, cmd.RE_Attributes2);
                        SetDropDownListValue(RE_Attributes3, cmd.RE_Attributes3);
                        SetDropDownListValue(RE_Attributes4, cmd.RE_Attributes4);
                        SetDropDownListValue(RE_Attributes5, cmd.RE_Attributes5);
                        //SetDropDownListValue(RE_Attributes6, cmd.RE_Attributes6);
                        SetDropDownListValue(RE_Attributes7, cmd.RE_Attributes7);
                       
                        RE_SA_Customer_Division_K4.Checked = cmd.RE_SA_Customer_Division_K4 == "1";
                        RE_SA_Customer_Division_K5.Checked = cmd.RE_SA_Customer_Division_K5 == "1";
                        RE_SA_Switch_Off_Rounding.Checked = cmd.RE_SA_Switch_Off_Rounding == "1";
                        RE_SA_Relevant_For_POD.Checked = cmd.RE_SA_Relevant_For_POD == "1";
                        RE_SA_Rebate.Checked = cmd.RE_SA_Rebate == "1";
                        RE_SA_Price_Determin.Checked = cmd.RE_SA_Price_Determin == "1";
                        RE_SA_Complete_Delivery_Reqd_By_Law.Checked = cmd.RE_SA_Complete_Delivery_Reqd_By_Law == "1";
                        RE_CO_Payment_History_Record.Checked = cmd.RE_CO_Payment_History_Record == "1"; ;

                        #endregion

                    }
                    #endregion

                    #region 审批项初始化
                    switch(TaskAPI.Step)
                    {
                        case "Manager Approve":
                        case "Accounting Manager":
                        case "Finance Manager":
                            Assessment1.Option.Add(new t_AssessmentOption("Approve", "1", true));
                            Assessment1.Option.Add(new t_AssessmentOption("Return", "2", false));
                            break;
                        case "DMO Approve":
                        case "DMO Maintain":
                        case "DMO Check":
                            Assessment1.Option.Add(new t_AssessmentOption("Finish", "1", true));
                            Assessment1.Option.Add(new t_AssessmentOption("Return", "2", false));
                            break;
                        
                    }
                    #endregion
                }
                #endregion

                SetDefaultValue();

                #region 设置控件禁启用
                //bool flg = (TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit) ? true : false;

                SetEnable(flg, VD, SA2, Actions, DrpPriority,BA_Existed_Sold_To_Code, SA_Currency, BA_Country, RE_BA_Type, BA_Type, RE_BA_Country, RE_SA_Tax_Classification, SA_Tax_Classification, BA_Sales_Employee_Code, RE_SA_Currency, BA_Bill_Search_Term2, BA_Account_Group, BA_BPCS_Code, SA_Itcoterms2, SA_Departing_Country, RE_SA_Departing_Country, RE_SA_Itcoterms2, BA_Customer_Name_In_ZH, BA_Hierarchy_1, BA_Hierarchy_2, BA_Existed_Sold_To_Code_City, BA_Street4, BA_Existed_Sold_To_Code_Address, BA_Existed_Sold_To_Code_Contact_Preson, BA_Existed_Sold_To_Code_Tel, BA_Post_Code, BA_Email, BA_Fax, Internat_Name, Internat_Language, Internat_Address, Internat_City, Internat_Tel, Internat_Mobile, Internat_Mail, Internat_Fax, BA_Existed_Payer_To_Code, BA_Bill_Name1, BA_Bill_City, BA_Bill_Street4, BA_Bill_Address, BA_Bill_Contact_Person, BA_Bill_Tel, BA_Bill_Postal_Code, BA_Bill_Mail, BA_Bill_Fax, BA_Existed_Code, BA_Old_BPCS_Indirect, BA_Indirect_Name1, BA_Indirect_Name2, BA_Indirect_City, BA_Indirect_Street4, BA_Indirect_Address, BA_Indirect_Person, BA_Indirect_Tel, BA_Indirect_Postal_Code, BA_Indirect_Mail, BA_Indirect_Fax, BA_Indirect_Transportation_Zone, BA_APO_Group, BA_Transportation_Zone, BA_Instruction_Key, BA_Industry1, BA_Industry_Code2, BA_Industry_Code3, BA_City_Code, BA_Tax_Number2, BA_Bank_Key, BA_Bank_Name, BA_Account, SA_Partner_Function, SA_Partner_Number, SA_Customer_Description, Text_Internal, Text_Shipping, Text_Pay, Text_External, Attributes7, Attributes8, BA_Sales_Employee, BA_Region, BA_Language, BA_Default_BillTo, BA_Bill_City_Code, BA_Default_Indirect, BA_Bank_Country, CO_Recon_Account, CO_Payment_Terms, CO_Payment_Methods, SA_Sales_Office, SA_Delivery_Priority, SA_Shipping_Condition, BA_Cust_Pric, SA_Acct_Assgmt_Group, SA_Itcoterms, Attributes1, Attributes2, Attributes3, Attributes4, Attributes5, SA_Customer_Division_K4, SA_Customer_Division_K5, SA_Customer_Division_K4, SA_Customer_Division_K5, RE_BA_Existed_Sold_To_Code, RE_BA_BPCS_Code, RE_BA_Customer_Name_In_ZH, RE_BA_Hierarchy_1, RE_BA_Hierarchy_2, RE_BA_SoldTo_Code, RE_BA_Existed_Sold_To_Code_City, RE_BA_Street4, RE_BA_Existed_Sold_To_Code_Address, RE_BA_Existed_Sold_To_Code_Contact_Preson, RE_BA_Existed_Sold_To_Code_Tel, RE_BA_Post_Code, RE_BA_Email, RE_BA_Fax, RE_BA_Transportation_Zone, RE_BA_Industry_Code3, RE_BA_Tax_Number2, RE_BA_Bank_Key, RE_BA_Bank_Name, RE_BA_Account, RE_SA_Partner_Function, RE_SA_Partner_Number, RE_SA_Customer_Description, RE_Text_Internal, RE_Text_Shipping, RE_Text_Pay, RE_Text_External, RE_Attributes7, RE_Attributes8, RE_BA_Sales_Employee_Code, RE_BA_Sales_Employee, RE_BA_Region, RE_BA_Language, RE_BA_APO_Group, RE_BA_Instruction_Key, RE_BA_Industry1, RE_BA_Industry_Code2, RE_BA_City_Code, RE_BA_Bank_Country, RE_CO_Recon_Account, RE_CO_Payment_Terms, RE_CO_Payment_Methods, RE_SA_Sales_Office, RE_SA_Delivery_Priority, RE_SA_Shipping_Condition, RE_BA_Cust_Pric, RE_SA_Acct_Assgmt_Group, RE_SA_Itcoterms, RE_Attributes1, RE_Attributes2, RE_Attributes3, RE_Attributes4, RE_Attributes5, RE_SA_Customer_Division_K4, RE_SA_Customer_Division_K5);
                SetEnable(TaskAPI.Step == "DMO Maintain", SAP_Code);
                SetEnable(TaskAPI.Step == "DMO Approve" | TaskAPI.Step == "DMO Maintain" | TaskAPI.Step == "DMO Check", DMO_DrpPriority);
                SetVisible(TaskAPI.Step == "DMO Approve" | TaskAPI.Step == "DMO Maintain" | TaskAPI.Step == "DMO Check", P_DMO);
                Assessment1.Enable = TaskAPI.IsAllowSubmit;
                SetVisible(TaskAPI.IsAllowSubmit, Send, Split);

                SetVisible(Actions.SelectedValue != "1", P1,  P3);
                Attachment1.AllowDelete = TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit;
                Attachment1.AllowUpload = TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit;
                InitTabs();
                #endregion

                #region 加深颜色
                string item = null;
                string value = null;
                foreach (Control cr in this.Controls)
                {
                    if (cr is DropDownList)
                    {
                        DropDownList tb = (DropDownList)cr;
                        if (!tb.Enabled)
                        {
                            tb.Enabled = true;
                            item = tb.SelectedItem.Text;
                            value = tb.SelectedValue.ToString();
                            tb.Items.Clear();
                            tb.Items.Add(new ListItem(item, value));
                        }
                        tb.ForeColor = System.Drawing.Color.DimGray;
                    }
                }
                if (!flg || !TaskAPI.IsAllowSubmit)
                {

                    foreach (Control cr in P_VD.Controls)
                    {
                        if (cr is DropDownList)
                        {
                            DropDownList tb = (DropDownList)cr;
                            if (!tb.Enabled)
                            {
                                tb.Enabled = true;
                                tb.ForeColor = System.Drawing.Color.DimGray;
                            }
                        }
                    }

                    foreach (Control cr in P_VD.Controls)
                    {
                        if (cr is TextBox)
                        {
                            TextBox tb = (TextBox)cr;
                            if (!tb.Enabled)
                            {
                                tb.Enabled = true;
                                tb.ReadOnly = true;
                                tb.ForeColor = System.Drawing.Color.DimGray;
                            }
                        }
                    }

                  
                    foreach (Control cr in P_SA2.Controls)
                    {
                        if (cr is DropDownList)
                        {
                            DropDownList tb = (DropDownList)cr;
                            if (!tb.Enabled)
                            {
                                tb.Enabled = true;
                                tb.ForeColor = System.Drawing.Color.DimGray;
                            }
                        }
                    }

                    foreach (Control cr in P_SA2.Controls)
                    {
                        if (cr is TextBox)
                        {
                            TextBox tb = (TextBox)cr;
                            if (!tb.Enabled)
                            {
                                tb.Enabled = true;
                                tb.ReadOnly = true;
                                tb.ForeColor = System.Drawing.Color.DimGray;
                            }
                        }
                    }

                   
                }

                #endregion
            }
        }
        #endregion

        #region 事件 Send
        protected void Send_Click(object sender, EventArgs e)
        {
            try
            {
                #region 数据验证
                if (TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit) // 如果是退回的情况，不存在验证
                {
                    List<string> vald_s = new List<string>();
                    vald_s.AddRange(DataValidation());
                    if (vald_s.Count > 0)
                    {
                        Anthem.Manager.AddScriptForClientSideEval(string.Format("ShowMessage(\"{0}\", {1});", CombineMessage(vald_s), vald_s.Count));
                        return;
                    }
                }
                #endregion

                #region 引擎传值
                if (TaskAPI.IsBeginStep)
                {
                    if (TaskAPI.IsInitiate)
                    {
                        ApplicationNo.Text        = Util.GenerateSequence(((object[])TaskAPI["PrefixNo"])[0].ToString() + "-" + System.DateTime.Now.ToString("yyMM"), "", 4);
                        TaskAPI.UserName          = UserAPI.UserName;
                        TaskAPI["ApplicationNo"]  = ApplicationNo.Text;
                        TaskAPI["ApplicatorName"] = UserAPI.UserFullName;
                        TaskAPI["Applicator"]     = UserAPI.UserName;
                        TaskAPI["Time"]           = System.DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss");
                        TaskAPI["ApplicatorEmail"] = UserAPI.Mail;
                        TaskAPI["Department"]     = UserAPI.Department;
                        TaskAPI["ServerName"] = Util.AppSettings("ServerName");
                    }
                    
                    TaskAPI.Summary = (Actions.SelectedItem.Text.Split(',').Length >= 2 ? Actions.SelectedItem.Text.Split(',')[1].Trim() : Actions.Text)
                                    + " / " + ApplicationNo.Text + (VD.Checked ? " / Customer " : "") + (SA2.Checked ? " / Rebate " : "");

                    //TaskAPI["finance_Type"] = VD.Checked && VD_finance_Type.SelectedValue == "内部(Internal)" ? "Internal" : "";
                    TaskAPI["Actions"]        = Actions.SelectedValue;
                    TaskAPI["Remark_by_Initiator"] = Assessment1.Assessment.Remark;
                    TaskAPI["DrpPriority"] = DrpPriority.SelectedItem.Text;

                    #region 从数据库取得流程步骤处理人
                    SortedList<string, string> rec_a = new SortedList<string, string>();

                    IList<mdc_Recipient> rec_s = (mdc_Recipient.process == TaskAPI.Process & (mdc_Recipient.distribute == Actions.SelectedValue | mdc_Recipient.distribute == "*") & mdc_Recipient.status == 1).List<mdc_Recipient>();
                    foreach (mdc_Recipient rec in rec_s)
                    {
                        if (!rec_a.ContainsKey(rec.Step))
                        {
                            rec_a.Add(rec.Step, rec.Recipient);
                            continue;
                        }

                        if (rec_a.Values[rec_a.IndexOfKey(rec.Step)].Contains(rec.Recipient))
                        {
                            continue;
                        }

                        rec_a[rec.Step] = rec_a.Values[rec_a.IndexOfKey(rec.Step)] + "," + rec.Recipient;
                    }

                    //步骤处理人赋值
                    for (int i = 0; i < rec_a.Keys.Count; i++)
                    {
                        TaskAPI["R_" + rec_a.Keys[i].Replace(" ", "_")] = rec_a.Values[i].Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    }

                    //m_OrgChart oc = (m_OrgChart.empID.In(m_OrgChart.dr2EmpID, m_OrgChart.winID == UserAPI.UserName)).ListFirst<m_OrgChart>();
                    //if(oc != null)
                    //{
                    //    TaskAPI["R_Manager_Approve2"] = oc.WinID;
                    //}

                    #endregion
                }
                else
                {
                    TaskAPI["ApproveResult"] = Assessment1.Assessment.Opinion;
                    TaskAPI["TaskID"]        = TaskAPI.TaskID;
                }

                
              
                #endregion

                #region 提交步骤
                bool flg=false;
                Storage.TransactionExecute(o =>
                {
                    #region “Fill in the form”步骤
                    if (TaskAPI.IsBeginStep)
                    {
                        TW_cmd_Customer_PKG cmd = new TW_cmd_Customer_PKG();
                        if ((TW_cmd_Customer_PKG.process == TaskAPI.Process & TW_cmd_Customer_PKG.incident == TaskAPI.Incident & TW_cmd_Customer_PKG.userName == UserAPI.UserName).Count<TW_cmd_Customer_PKG>() > 0)
                        {
                            cmd = (TW_cmd_Customer_PKG.process == TaskAPI.Process & TW_cmd_Customer_PKG.incident == TaskAPI.Incident & TW_cmd_Customer_PKG.userName == UserAPI.UserName).ListFirst<TW_cmd_Customer_PKG>();
                        }
                        else
                        {
                            cmd.Process = TaskAPI.Process;
                            cmd.Incident = TaskAPI.Incident;
                            cmd.UserName = UserAPI.UserName;
                            cmd.UserFullName = UserAPI.UserFullName;
                            cmd.ApplicationNo = ApplicationNo.Text;
                            cmd.Time = System.DateTime.Now;
                            cmd.Status = 0;
                            cmd.Department = UserAPI.Department;
                        }

                        cmd.Actions            = Actions.SelectedValue;
                        cmd.DrpPriority = DrpPriority.SelectedValue;
                        //finance.Actions           = Actions.SelectedItem.Text;

                        cmd.VD_Checked        = VD.Checked ? "1" : "0";
                        cmd.SA2_Checked = SA2.Checked ? "1" : "0";
                       
                       
                        #region VD
                        if (VD.Checked)
                        {
                            cmd.BA_Existed_Sold_To_Code = BA_Existed_Sold_To_Code.Text;
                            cmd.BA_BPCS_Code = BA_BPCS_Code.Text;
                            cmd.BA_Customer_Name_In_ZH = BA_Customer_Name_In_ZH.Text;
                            cmd.BA_Search_Term_1 = BA_Search_Term_1.Text;
                            cmd.BA_Search_Term_2 = BA_Search_Term_2.Text;
                            cmd.BA_Hierarchy_1 = BA_Hierarchy_1.Text;
                            cmd.BA_Hierarchy_2 = BA_Hierarchy_2.Text;
                            cmd.BA_Sales_Employee_Code = BA_Sales_Employee_Code.Text;
                            cmd.BA_Sales_Employee = BA_Sales_Employee.Text;
                          
                            cmd.BA_Existed_Sold_To_Code_City = BA_Existed_Sold_To_Code_City.Text;
                            cmd.BA_Street4 = BA_Street4.Text;
                            cmd.BA_Existed_Sold_To_Code_Address = BA_Existed_Sold_To_Code_Address.Text;
                            cmd.BA_Existed_Sold_To_Code_Contact_Preson = BA_Existed_Sold_To_Code_Contact_Preson.Text;
                            cmd.BA_Existed_Sold_To_Code_Tel = BA_Existed_Sold_To_Code_Tel.Text;
                            cmd.BA_Post_Code = BA_Post_Code.Text;
                            cmd.BA_Email = BA_Email.Text;
                            cmd.BA_Fax = BA_Fax.Text;
                            cmd.Internat_Name = Internat_Name.Text;
                            cmd.Internat_Seach_Term = Internat_Seach_Term.Text;
                            cmd.Internat_Language = Internat_Language.Text;
                            cmd.Internat_Address = Internat_Address.Text;
                            cmd.Internat_City = Internat_City.Text;
                            cmd.Internat_Tel = Internat_Tel.Text;
                            cmd.Internat_Mobile = Internat_Mobile.Text;
                            cmd.Internat_Mail = Internat_Mail.Text;
                            cmd.Internat_Fax = Internat_Fax.Text;
                            cmd.BA_Existed_Payer_To_Code = BA_Existed_Payer_To_Code.Text;
                            cmd.BA_Bill_Name1 = BA_Bill_Name1.Text;
                            cmd.BA_Bill_Search_Term1 = BA_Bill_Search_Term1.Text;
                            cmd.BA_Bill_Search_Term2 = BA_Bill_Search_Term2.Text;
                            cmd.BA_Bill_City = BA_Bill_City.Text;
                            cmd.BA_Bill_County_Code = BA_Bill_County_Code.Text;
                            cmd.BA_Bill_Street4 = BA_Bill_Street4.Text;
                            cmd.BA_Bill_Address = BA_Bill_Address.Text;
                            cmd.BA_Bill_Contact_Person = BA_Bill_Contact_Person.Text;
                            cmd.BA_Bill_Tel = BA_Bill_Tel.Text;
                            cmd.BA_Bill_Postal_Code = BA_Bill_Postal_Code.Text;
                            cmd.BA_Bill_Mail = BA_Bill_Mail.Text;
                            cmd.BA_Bill_Fax = BA_Bill_Fax.Text;
                            cmd.BA_Existed_Code = BA_Existed_Code.Text;
                            cmd.BA_Old_BPCS_Indirect = BA_Old_BPCS_Indirect.Text;
                            cmd.BA_Indirect_Name1 = BA_Indirect_Name1.Text;
                            cmd.BA_Indirect_Name2 = BA_Indirect_Name2.Text;
                            cmd.BA_Indirect_Search_Term1 = BA_Indirect_Search_Term1.Text;
                            cmd.BA_Indirect_Search_Term2 = BA_Indirect_Search_Term2.Text;
                            cmd.BA_Indirect_City = BA_Indirect_City.Text;
                            cmd.BA_Indirect_Street4 = BA_Indirect_Street4.Text;
                            cmd.BA_Indirect_Address = BA_Indirect_Address.Text;
                            cmd.BA_Indirect_Person = BA_Indirect_Person.Text;
                            cmd.BA_Indirect_Tel = BA_Indirect_Tel.Text;
                            cmd.BA_Indirect_Postal_Code = BA_Indirect_Postal_Code.Text;
                            cmd.BA_Indirect_Mail = BA_Indirect_Mail.Text;
                            cmd.BA_Indirect_Fax = BA_Indirect_Fax.Text;
                            //cmd.BA_Indirect_Transportation_Zone = BA_Indirect_Transportation_Zone.Text;
                            cmd.BA_Industry_Code2 = BA_Industry_Code2.Text;
                            cmd.BA_County_Code = BA_County_Code.Text;
                            cmd.BA_Tax_Number2 = BA_Tax_Number2.Text;
                            cmd.BA_Bank_Key = BA_Bank_Key.Text;
                            cmd.BA_Bank_Name = BA_Bank_Name.Text;
                            cmd.BA_Account = BA_Account.Text;
                            cmd.BA_Acct_Holder = BA_Acct_Holder.Text;
                            cmd.CO_Company = CO_Company.Text;
                            cmd.CO_Sort_Key = CO_Sort_Key.Text;
                            cmd.CO_BPCS = CO_BPCS.Text;
                            cmd.CO_Cash_Mgmt = CO_Cash_Mgmt.Text;
                            cmd.CO_Bank_Statement = CO_Bank_Statement.Text;
                            cmd.CO_Dunn_Procedure = CO_Dunn_Procedure.Text;
                            cmd.SA_Sales_Org = SA_Sales_Org.Text;
                            cmd.SA_Order_Combination = SA_Order_Combination.Text;
                            cmd.SA_Partial_Delivery_Per_Item = SA_Partial_Delivery_Per_Item.Text;
                            cmd.SA_Tax_Classification = SA_Tax_Classification.Text;
                            cmd.SA_Itcoterms2 = SA_Itcoterms2.Text;
                            cmd.SA_Departing_Country = SA_Departing_Country.Text;
                            cmd.SA_Customer_Group_3 = SA_Customer_Group_3.Text;
                            cmd.SA_Partner_Function = SA_Partner_Function.Text;
                            cmd.SA_Partner_Number = SA_Partner_Number.Text;
                            cmd.SA_Customer_Description = SA_Customer_Description.Text;
                            cmd.SA_Sales_Code = SA_Sales_Code.Text;
                            cmd.Text_Internal = Text_Internal.Text;
                            cmd.Text_Shipping = Text_Shipping.Text;
                            cmd.Text_Pay = Text_Pay.Text;
                            cmd.Text_External = Text_External.Text;
                            cmd.Attributes8 = Attributes8.Text;
                            cmd.Attributes9 = Attributes9.Text;
                            cmd.SA_Terms_Of_Payment = SA_Terms_Of_Payment.Text;
                            cmd.SA_Distribution_Channel = SA_Distribution_Channel.Text;
                            cmd.BA_Industry_Code3 = BA_Industry_Code3.Text;
                            cmd.SA_Delivering_Plant = SA_Delivering_Plant.Text;
                            cmd.BA_Industry = BA_Industry.Text;

                            cmd.BA_Type = BA_Type.SelectedValue;
                            cmd.BA_Country = BA_Country.SelectedValue;
                            cmd.BA_Indirect_Transportation_Zone = BA_Indirect_Transportation_Zone.SelectedValue;
                            cmd.BA_Transportation_Zone = BA_Transportation_Zone.SelectedValue;
                            cmd.BA_Account_Group = BA_Account_Group.SelectedValue;
                            cmd.BA_Region = BA_Region.SelectedValue;
                            cmd.BA_Language = BA_Language.SelectedValue;
                            cmd.BA_Default_BillTo = BA_Default_BillTo.SelectedValue;
                            cmd.BA_Bill_City_Code = BA_Bill_City_Code.SelectedValue;
                            cmd.BA_Default_Indirect = BA_Default_Indirect.SelectedValue;
                            //cmd.BA_Industry = BA_Industry.SelectedValue;
                            cmd.BA_Bank_Country = BA_Bank_Country.SelectedValue;
                            cmd.CO_Recon_Account = CO_Recon_Account.SelectedValue;
                            cmd.CO_Payment_Terms = CO_Payment_Terms.SelectedValue;
                            cmd.CO_Payment_Methods = CO_Payment_Methods.SelectedValue;
                            cmd.SA_Sales_Office = SA_Sales_Office.SelectedValue;
                            cmd.SA_Delivery_Priority = SA_Delivery_Priority.SelectedValue;
                            cmd.SA_Shipping_Condition = SA_Shipping_Condition.SelectedValue;
                            cmd.BA_Cust_Pric = BA_Cust_Pric.SelectedValue;
                            cmd.SA_Acct_Assgmt_Group = SA_Acct_Assgmt_Group.SelectedValue;
                            cmd.SA_Itcoterms = SA_Itcoterms.SelectedValue;
                            cmd.SA_Max_Partial_Deliveries_1 = SA_Max_Partial_Deliveries_1.Text;
                            cmd.Attributes1 = Attributes1.SelectedValue;
                            cmd.Attributes2 = Attributes2.SelectedValue;
                            cmd.Attributes3 = Attributes3.SelectedValue;
                            cmd.Attributes4 = Attributes4.SelectedValue;
                            cmd.Attributes5 = Attributes5.SelectedValue;
                           //cmd.Attributes6 = Attributes6.SelectedValue;
                            cmd.Attributes7 = Attributes7.SelectedValue;
                            cmd.BA_City_Code = BA_City_Code.SelectedValue;
                            cmd.BA_APO_Group = BA_APO_Group.SelectedValue;
                            cmd.BA_Industry1 = BA_Industry1.SelectedValue;
                            cmd.BA_Instruction_Key = BA_Instruction_Key.SelectedValue;
                            cmd.SA_Currency = SA_Currency.SelectedValue;

                            cmd.SA_Customer_Division_K4 = SA_Customer_Division_K4.Checked ? "1" : "0";
                            cmd.SA_Customer_Division_K5 = SA_Customer_Division_K5.Checked ? "1" : "0";
                            cmd.SA_Switch_Off_Rounding = SA_Switch_Off_Rounding.Checked ? "1" : "0";
                            cmd.SA_Relevant_For_POD = SA_Relevant_For_POD.Checked ? "1" : "0";
                            cmd.SA_Rebate = SA_Rebate.Checked ? "1" : "0";
                            cmd.SA_Price_Determin = SA_Price_Determin.Checked ? "1" : "0";
                            cmd.SA_Complete_Delivery_Reqd_By_Law = SA_Complete_Delivery_Reqd_By_Law.Checked ? "1" : "0";
                            cmd.CO_Payment_History_Record = CO_Payment_History_Record.Checked ? "1" : "0";

                        }
                        #endregion

                        #region SA2
                        if (SA2.Checked)
                        {
                            cmd.RE_BA_Existed_Sold_To_Code = RE_BA_Existed_Sold_To_Code.Text;
                            cmd.RE_BA_Account_Group = RE_BA_Account_Group.Text;
                            cmd.RE_BA_BPCS_Code = RE_BA_BPCS_Code.Text;
                            cmd.RE_BA_Customer_Name_In_ZH = RE_BA_Customer_Name_In_ZH.Text;
                            cmd.RE_BA_Search_Term_1 = RE_BA_Search_Term_1.Text;
                            cmd.RE_BA_Search_Term_2 = RE_BA_Search_Term_2.Text;
                            cmd.RE_BA_Hierarchy_1 = RE_BA_Hierarchy_1.Text;
                            cmd.RE_BA_Hierarchy_2 = RE_BA_Hierarchy_2.Text;
                            cmd.RE_BA_Sales_Employee_Code = RE_BA_Sales_Employee_Code.Text;
                            cmd.RE_BA_Sales_Employee = RE_BA_Sales_Employee.Text;
                           
                            cmd.RE_BA_Existed_Sold_To_Code_City = RE_BA_Existed_Sold_To_Code_City.Text;
                            cmd.RE_BA_SoldTo_Code = RE_BA_SoldTo_Code.Text;
                            cmd.RE_BA_Street4 = RE_BA_Street4.Text;
                            cmd.RE_BA_Existed_Sold_To_Code_Address = RE_BA_Existed_Sold_To_Code_Address.Text;
                            cmd.RE_BA_Existed_Sold_To_Code_Contact_Preson = RE_BA_Existed_Sold_To_Code_Contact_Preson.Text;
                            cmd.RE_BA_Existed_Sold_To_Code_Tel = RE_BA_Existed_Sold_To_Code_Tel.Text;
                            cmd.RE_BA_Post_Code = RE_BA_Post_Code.Text;
                            cmd.RE_BA_Email = RE_BA_Email.Text;
                            cmd.RE_BA_Fax = RE_BA_Fax.Text;
                            //cmd.RE_BA_Transportation_Zone = RE_BA_Transportation_Zone.Text;
                            cmd.RE_BA_County_Code = RE_BA_County_Code.Text;
                            cmd.RE_BA_Tax_Number2 = RE_BA_Tax_Number2.Text;
                            cmd.RE_BA_Bank_Key = RE_BA_Bank_Key.Text;
                            cmd.RE_BA_Bank_Name = RE_BA_Bank_Name.Text;
                            cmd.RE_BA_Account = RE_BA_Account.Text;
                            cmd.RE_BA_Acct_Holder = RE_BA_Acct_Holder.Text;
                            cmd.RE_CO_Company = RE_CO_Company.Text;
                            cmd.RE_CO_Sort_Key = RE_CO_Sort_Key.Text;
                            cmd.RE_CO_BPCS = RE_CO_BPCS.Text;
                            cmd.RE_CO_Cash_Mgmt = RE_CO_Cash_Mgmt.Text;
                            cmd.RE_CO_Bank_Statement = RE_CO_Bank_Statement.Text;
                            cmd.RE_CO_Dunn_Procedure = RE_CO_Dunn_Procedure.Text;
                            cmd.RE_SA_Sales_Org = RE_SA_Sales_Org.Text;
                            cmd.RE_SA_Partial_Delivery_Per_Item = RE_SA_Partial_Delivery_Per_Item.Text;
                            cmd.RE_SA_Max_Partial_Deliveries_1 = RE_SA_Max_Partial_Deliveries_1.Text;
                            cmd.RE_SA_Order_Combination = RE_SA_Order_Combination.Text;
                            cmd.RE_SA_Tax_Classification = RE_SA_Tax_Classification.Text;
                            cmd.RE_SA_Itcoterms2 = RE_SA_Itcoterms2.Text;
                            cmd.RE_SA_Departing_Country = RE_SA_Departing_Country.Text;
                            cmd.RE_SA_Terms_Of_Payment = RE_SA_Terms_Of_Payment.Text;
                            cmd.RE_SA_Customer_Group_3 = RE_SA_Customer_Group_3.Text;
                            cmd.RE_SA_Partner_Function = RE_SA_Partner_Function.Text;
                            cmd.RE_SA_Partner_Number = RE_SA_Partner_Number.Text;
                            cmd.RE_SA_Customer_Description = RE_SA_Customer_Description.Text;
                            cmd.RE_SA_Sales_Code = RE_SA_Sales_Code.Text;
                            cmd.RE_Text_Internal = RE_Text_Internal.Text;
                            cmd.RE_Text_Shipping = RE_Text_Shipping.Text;
                            cmd.RE_Text_Pay = RE_Text_Pay.Text;
                            cmd.RE_Text_External = RE_Text_External.Text;
                            //cmd.RE_Attributes6 = RE_Attributes6.Text;
                            cmd.RE_Attributes9 = RE_Attributes9.Text;
                            cmd.RE_BA_Industry_Code2 = RE_BA_Industry_Code2.Text;
                            cmd.RE_SA_Distribution_Channel = RE_SA_Distribution_Channel.Text;
                            cmd.RE_BA_Industry_Code3 = RE_BA_Industry_Code3.Text;
                            cmd.RE_Attributes8 = RE_Attributes8.Text;
                            cmd.RE_SA_Delivering_Plant = RE_SA_Delivering_Plant.Text;
                            cmd.RE_BA_Industry = RE_BA_Industry.Text;

                            cmd.RE_BA_Type = RE_BA_Type.SelectedValue;
                            cmd.RE_BA_Region = RE_BA_Region.SelectedValue;
                            cmd.RE_BA_Country = RE_BA_Country.SelectedValue;
                            cmd.RE_BA_Transportation_Zone = RE_BA_Transportation_Zone.SelectedValue;
                            cmd.RE_BA_Language = RE_BA_Language.SelectedValue;
                            //cmd.RE_BA_Industry = RE_BA_Industry.SelectedValue;
                            cmd.RE_BA_Industry1 = RE_BA_Industry1.SelectedValue;
                            cmd.RE_BA_Instruction_Key = RE_BA_Instruction_Key.SelectedValue;
                            cmd.RE_BA_APO_Group = RE_BA_APO_Group.SelectedValue;
                            cmd.RE_BA_City_Code = RE_BA_City_Code.SelectedValue;
                            cmd.RE_BA_Bank_Country = RE_BA_Bank_Country.SelectedValue;
                            cmd.RE_CO_Recon_Account = RE_CO_Recon_Account.SelectedValue;
                            cmd.RE_CO_Payment_Terms = RE_CO_Payment_Terms.SelectedValue;
                            cmd.RE_CO_Payment_Methods = RE_CO_Payment_Methods.SelectedValue;
                            cmd.RE_SA_Sales_Office = RE_SA_Sales_Office.SelectedValue;
                            cmd.RE_SA_Delivery_Priority = RE_SA_Delivery_Priority.SelectedValue;
                            cmd.RE_SA_Shipping_Condition = RE_SA_Shipping_Condition.SelectedValue;
                            cmd.RE_BA_Cust_Pric = RE_BA_Cust_Pric.SelectedValue;
                            cmd.RE_SA_Acct_Assgmt_Group = RE_SA_Acct_Assgmt_Group.SelectedValue;
                            cmd.RE_SA_Itcoterms = RE_SA_Itcoterms.SelectedValue;
                            cmd.RE_Attributes1 = RE_Attributes1.SelectedValue;
                            cmd.RE_Attributes2 = RE_Attributes2.SelectedValue;
                            cmd.RE_Attributes3 = RE_Attributes3.SelectedValue;
                            cmd.RE_Attributes4 = RE_Attributes4.SelectedValue;
                            cmd.RE_Attributes5 = RE_Attributes5.SelectedValue;
                            cmd.RE_Attributes7 = RE_Attributes7.SelectedValue;
                            cmd.RE_SA_Currency = RE_SA_Currency.SelectedValue;
                           

                            cmd.RE_SA_Customer_Division_K4 = RE_SA_Customer_Division_K4.Checked ? "1" : "0";
                            cmd.RE_SA_Customer_Division_K5 = RE_SA_Customer_Division_K5.Checked ? "1" : "0";
                            cmd.RE_SA_Switch_Off_Rounding = RE_SA_Switch_Off_Rounding.Checked ? "1" : "0";
                            cmd.RE_SA_Relevant_For_POD = RE_SA_Relevant_For_POD.Checked ? "1" : "0";
                            cmd.RE_SA_Rebate = RE_SA_Rebate.Checked ? "1" : "0";
                            cmd.RE_SA_Price_Determin = RE_SA_Price_Determin.Checked ? "1" : "0";
                            cmd.RE_SA_Complete_Delivery_Reqd_By_Law = RE_SA_Complete_Delivery_Reqd_By_Law.Checked ? "1" : "0";
                            cmd.RE_CO_Payment_History_Record = RE_CO_Payment_History_Record.Checked ? "1" : "0";


                        }
                        #endregion

                    

                        (t_Attachment.process == TaskAPI.Process & t_Attachment.incident == 0 & t_Attachment.username == UserAPI.UserName).Edit<t_Attachment>(p =>
                        {
                            p.Incident = TaskAPI.Incident;
                        });

                        Storage.Save(Storage.Context1, cmd);
                    }
                    #endregion

                    #region Priority功能
                    if (TaskAPI.IsBeginStep && !string.IsNullOrEmpty(DrpPriority.SelectedValue))
                    {
                        mdc_Priority pro;
                        if ((mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).Count<mdc_Priority>() > 0)
                        {
                            pro = new mdc_Priority();
                            pro = (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).ListFirst<mdc_Priority>();
                            pro.Business_Priority = Convert.ToInt32(DrpPriority.SelectedValue);
                            Storage.Save(pro);
                        }
                        else
                        {
                            pro = new mdc_Priority();
                            pro.Process = TaskAPI.Process;
                            pro.Incident = TaskAPI.Incident;
                            pro.Business_Priority = Convert.ToInt32(DrpPriority.SelectedValue);
                            Storage.Save(pro);
                        }

                    }


                    if ((TaskAPI.Step == "DMO Maintain" || TaskAPI.Step == "DMO Approve" || TaskAPI.Step == "DMO Check") && !string.IsNullOrEmpty(this.DMO_DrpPriority.SelectedValue) && !string.IsNullOrEmpty(DrpPriority.SelectedValue))
                    {

                        //mdc_Priority pro;
                        //pro = (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).ListFirst<mdc_Priority>();
                        //pro.DMO_Priority = Convert.ToInt32(DMO_DrpPriority.SelectedValue);
                        //Storage.Save(pro);
                        mdc_Priority pro;
                        if ((mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).Count<mdc_Priority>() > 0)
                        {
                            pro = (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).ListFirst<mdc_Priority>();
                            pro.DMO_Priority = Convert.ToInt32(DMO_DrpPriority.SelectedValue);
                            Storage.Save(pro);
                        }
                        else
                        {
                            pro = (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).ListFirst<mdc_Priority>();
                            pro.DMO_Priority = Convert.ToInt32(DMO_DrpPriority.SelectedValue);
                            Storage.Save(pro);
                        }


                    }
                    #endregion

                    #region “DMO Maintain”步骤
                    if (TaskAPI.Step == "DMO Maintain")
                    {
                        (TW_cmd_Customer_PKG.process == TaskAPI.Process & TW_cmd_Customer_PKG.incident == TaskAPI.Incident).Edit<TW_cmd_Customer_PKG>(p =>
                        {
                            p.SAP_Code = SAP_Code.Text;
                        }
                        );
                    }

                    if (TaskAPI.Step == "DMO Maintain" || TaskAPI.Step == "DMO Approve" || TaskAPI.Step == "DMO Check")
                    {

                        TaskAPI["DMO_DrpPriority"] = DMO_DrpPriority.SelectedItem.Text;
                        (TW_cmd_Customer_PKG.process == TaskAPI.Process & TW_cmd_Customer_PKG.incident == TaskAPI.Incident).Edit<TW_cmd_Customer_PKG>(p =>
                        {
                            // p.SAP_Code = SAP_Code.Text;
                            p.DMO_DrpPriority = DMO_DrpPriority.SelectedValue;

                        }
                        );
                    }
                    #endregion

                    Storage.Save(Assessment1.Assessment);    //审批意见

                    //多节点退回
                    if (!string.IsNullOrEmpty(Assessment1.JumpStep))
                    {
                        Assessment1.SetAsReturn(true);
                        TaskAPI.DirectActive(Assessment1.JumpStep);
                    }
                    else
                    {
                        Assessment1.SetAsReturn(false);
                    }
                    Assessment1.SubmitTo();
                    flg = TaskAPI.Send();
                });

                //如果数据库写入成功且流程发起成功的情况，将业务表数据与流程实例号进行关联
                if (TaskAPI.IsInitiate)
                {
                    if (!string.IsNullOrEmpty(DrpPriority.SelectedValue))
                    {
                        (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == 0).Edit<mdc_Priority>(p =>
                        {
                            p.Incident = TaskAPI.Incident;
                        });
                    }
                    (TW_cmd_Customer_PKG.process == TaskAPI.Process & TW_cmd_Customer_PKG.incident == 0 & TW_cmd_Customer_PKG.userName == UserAPI.UserName).Edit<TW_cmd_Customer_PKG>(p => 
                    {
                        p.Incident = TaskAPI.Incident;
                    });

                    (t_Assessment.process == TaskAPI.Process & t_Assessment.incident == 0 & t_Assessment.assignedToUserName == UserAPI.UserName).Edit<t_Assessment>(p =>
                    {
                        p.Incident = TaskAPI.Incident;
                    });


                    (t_Attachment.process == TaskAPI.Process & t_Attachment.incident == 0 & t_Attachment.username == UserAPI.UserName).Edit<t_Attachment>(p =>
                    {
                        p.Incident = TaskAPI.Incident;
                    });
                }
                #endregion

                Send.Visible = false;
                Anthem.Manager.AddScriptForClientSideEval("JSInfomation('" + Resources.Global.C_00_Success + "',true)");
            }
            catch (Exception ex)
            {
                TaskDB.Log("", false, "调用NVA方法Send_Click出错：" + ex.ToString());
                Anthem.Manager.AddScriptForClientSideEval("JSInfomation('" + Resources.Global.C_00_Failed + "',false)");
            }
        }
        #endregion

        #region 事件 CheckedChanged
        protected void VD_CheckedChanged(object sender, EventArgs e)
        {

            if (!VD.Checked &&  !SA2.Checked )
            {
                Anthem.Manager.AddScriptForClientSideEval("JSInfomation('至少保留一个选择项！',false)");
                VD.Checked = true;
            }
          
            SetVisible(false,P_VD,P_SA2);
            switch(((Anthem.CheckBox)sender).ID)
            {
                case "VD":
                    
                    if (VD.Checked)
                    {
                        //SA.Checked = false;
                        //SA2.Checked = false;
                        //SA3.Checked = false;
                        VD_L.Visible = VD.Checked;
                    }
                    //VD.Checked = !(SA.Checked | SA2.Checked);

                    //VD_L.Visible = VD.Checked;
                    break;
              
                
                case "SA2":
                    if (SA2.Checked)
                    {
                        //VD.Checked = false;
                        //SA.Checked = false;
                        //SA3.Checked = false;
                        SA2_L.Visible = SA2.Checked;
                    }

                    //SA2_L.Visible = SA2.Checked;
                    //if (!SA.Checked & !SA2.Checked) SA2.Checked = true;
                    //VD.Checked = !(SA.Checked | SA2.Checked);
                    //SA2_L.Visible = SA2.Checked;
                    break;

               
            }
           
            InitTabs();
        }
        #endregion
       
        #region 事件 Actions变换
        protected void Actions_SelectedIndexChanged(object sender, EventArgs e)
        {
            SetColor();
            SetEnable((Actions.SelectedValue == "1" || Actions.SelectedValue == "2" || Actions.SelectedValue == "3" || Actions.SelectedValue == "4"));
            if (Actions.SelectedValue != "1")
            {
                SetVisible(true, P1,  P3);
            }
            else
            {
                SetVisible(false, P1,  P3);
            }
        }
        #endregion

        #region 事件 Tabs切换
        protected void Tabs_Click(object sender, EventArgs e)
        {
            if (((LinkButton)sender).CssClass == "tabs2")
            {
                return;
            }

            #region 初始化
            SetVisible(false, P_VD,  P_SA2);
            VD_L.CssClass = "tabs1";
           
            SA2_L.CssClass = "tabs1";
           
            #endregion

            #region Tabs切换动作
            switch (((LinkButton)sender).ID)
            {
                case "VD_L":
                    VD_L.CssClass = "tabs2";
                    P_VD.Visible = true;
                    break;
               
                case "SA2_L":
                    SA2_L.CssClass = "tabs2";
                    P_SA2.Visible = true;
                    break;
             
            }
            #endregion
        }
        #endregion

        #region 方法 初始化Tabs
        protected void InitTabs()
        {
            VD_L.Visible = VD.Checked;
            SA2_L.Visible = SA2.Checked;
           
           

            SetVisible(false, P_VD,P_SA2);
            VD_L.CssClass = "tabs1";
           
            SA2_L.CssClass = "tabs1";
           

            //默认第1个显示 Tabs被选中
            if (VD_L.Visible)
            {
                VD_L.CssClass = "tabs2";
                P_VD.Visible = true;
                return;
            }


            if (SA2_L.Visible)
            {
                SA2_L.CssClass = "tabs2";
                P_SA2.Visible = true;
                return;
            }
 
        }
        #endregion

        #region 方法 SetColor
        protected void SetColor()
        {
            SetForeColor(Color.Black, BA_Existed_Sold_To_Code_L, BA_Indirect_Transportation_Zone_L, BA_Transportation_Zone_L, RE_BA_Transportation_Zone_L, BA_Country_L, RE_BA_Country_L, SA_Currency_L, RE_SA_Currency_L, RE_BA_Type_L, BA_Type_L, RE_BA_Existed_Sold_To_Code_L, BA_Account_Group_L, BA_Customer_Name_In_ZH_L, BA_Existed_Sold_To_Code_City_L, BA_Existed_Sold_To_Code_Address_L, BA_Account_Group_L, BA_Language_L, CO_Recon_Account_L, CO_Payment_Terms_L, CO_Payment_Methods_L, SA_Delivery_Priority_L, SA_Shipping_Condition_L, BA_Cust_Pric_L, SA_Acct_Assgmt_Group_L, SA_Itcoterms_L, RE_BA_Customer_Name_In_ZH_L, RE_BA_SoldTo_Code_L, RE_BA_Existed_Sold_To_Code_City_L, RE_BA_Existed_Sold_To_Code_Address_L, RE_BA_Language_L, RE_CO_Recon_Account_L, RE_CO_Payment_Terms_L, RE_CO_Payment_Methods_L, RE_SA_Delivery_Priority_L, RE_SA_Shipping_Condition_L, RE_BA_Cust_Pric_L, RE_SA_Acct_Assgmt_Group_L, RE_SA_Itcoterms_L);
            
            switch (Actions.SelectedValue)
            {
                case "1":
                    SetForeColor(Color.Blue, BA_Account_Group_L, BA_Indirect_Transportation_Zone_L, BA_Transportation_Zone_L, RE_BA_Transportation_Zone_L, SA_Currency_L, BA_Country_L, RE_BA_Country_L, RE_SA_Currency_L, BA_Customer_Name_In_ZH_L, RE_BA_Type_L, BA_Type_L, BA_Existed_Sold_To_Code_City_L, BA_Existed_Sold_To_Code_Address_L, BA_Account_Group_L, BA_Language_L, CO_Recon_Account_L, CO_Payment_Terms_L, CO_Payment_Methods_L, SA_Delivery_Priority_L, SA_Shipping_Condition_L, BA_Cust_Pric_L, SA_Acct_Assgmt_Group_L, SA_Itcoterms_L, RE_BA_Customer_Name_In_ZH_L, RE_BA_SoldTo_Code_L, RE_BA_Existed_Sold_To_Code_City_L, RE_BA_Existed_Sold_To_Code_Address_L, RE_BA_Language_L, RE_CO_Recon_Account_L, RE_CO_Payment_Terms_L, RE_CO_Payment_Methods_L, RE_SA_Delivery_Priority_L, RE_SA_Shipping_Condition_L, RE_BA_Cust_Pric_L, RE_SA_Acct_Assgmt_Group_L, RE_SA_Itcoterms_L);
                    break;

                case "2":
                    SetForeColor(Color.Blue, BA_Existed_Sold_To_Code_L, RE_BA_Existed_Sold_To_Code_L, RE_BA_Type_L, BA_Type_L, BA_Customer_Name_In_ZH_L, RE_BA_Customer_Name_In_ZH_L);
                    break;

                case "3":
                    SetForeColor(Color.Blue, BA_Existed_Sold_To_Code_L, RE_BA_Existed_Sold_To_Code_L, RE_BA_Type_L, BA_Type_L, BA_Customer_Name_In_ZH_L, RE_BA_Customer_Name_In_ZH_L);
                    break;

                case "4":
                    SetForeColor(Color.Blue, BA_Existed_Sold_To_Code_L, RE_BA_Existed_Sold_To_Code_L, RE_BA_Type_L, BA_Type_L, BA_Customer_Name_In_ZH_L, RE_BA_Customer_Name_In_ZH_L);
                    break;
            }
        }
        #endregion

        #region 方法 SetDefaultValue(设置默认值, 并禁用输入)
        public void SetDefaultValue()
        {

            //BA_Country.Text="TW Taiwan";
            CO_Sort_Key.Text="031";
            CO_Cash_Mgmt.Text="";
            CO_Bank_Statement.Text="2";
            SA_Sales_Org.Text="TW01";
            SA_Distribution_Channel.Text = "10(3rd party)";
            SA_Order_Combination.Text="";
            //SA_Tax_Classification.Text="1";
            SA_Departing_Country.Text="TW";
            SA_Customer_Group_3.Text="001";
            SA_Partial_Delivery_Per_Item.Text="";
            SA_Delivering_Plant.Text = "KT2D";
            RE_SA_Delivering_Plant.Text = "KT2D";
            CO_Dunn_Procedure.Text="TW00";
            SA_Max_Partial_Deliveries_1.Text="9";
            RE_BA_Account_Group.Text = "Z001 Sold to-customer";
            //RE_BA_Country.Text="TW Taiwan";
            RE_CO_Sort_Key.Text="031";
            RE_CO_Cash_Mgmt.Text="";
            RE_CO_Bank_Statement.Text="2";
            RE_SA_Sales_Org.Text="TW01";
            RE_SA_Distribution_Channel.Text = "10(3rd party)";
            RE_SA_Partial_Delivery_Per_Item.Text="";
            RE_SA_Max_Partial_Deliveries_1.Text="9";
            RE_SA_Order_Combination.Text="";
            //RE_SA_Tax_Classification.Text="1";
            RE_SA_Departing_Country.Text="TW";
            RE_SA_Customer_Group_3.Text="001";
            RE_CO_Dunn_Procedure.Text="TW00";
            //BA_Indirect_Transportation_Zone.Text="TWOTH00000";
            //BA_Transportation_Zone.Text="TWOTH00000";
            //RE_BA_Transportation_Zone.Text="TWOTH00000";
            CO_Company.Text="4239";
            RE_CO_Company.Text="4239";
            BA_Industry.Text = "P03";
            RE_BA_Industry.Text = "P03";
            SA_Switch_Off_Rounding.Checked=true;
            SA_Relevant_For_POD.Checked=true;
            SA_Rebate.Checked=true;
            SA_Price_Determin.Checked=true;
            SA_Complete_Delivery_Reqd_By_Law.Checked=false;
            RE_SA_Switch_Off_Rounding.Checked=true;
            RE_SA_Relevant_For_POD.Checked=true;
            RE_SA_Rebate.Checked=true;
            RE_SA_Price_Determin.Checked=true;
            RE_SA_Complete_Delivery_Reqd_By_Law.Checked=false;
            CO_Payment_History_Record.Checked=true;
            RE_CO_Payment_History_Record.Checked=true;

            SetEnable(false, RE_BA_Account_Group, CO_Sort_Key, BA_Industry, RE_BA_Industry,SA_Delivering_Plant, RE_SA_Delivering_Plant, SA_Distribution_Channel, RE_SA_Distribution_Channel, CO_Cash_Mgmt, CO_Company, RE_CO_Company, CO_Payment_History_Record, CO_Bank_Statement, SA_Sales_Org, SA_Order_Combination,  SA_Customer_Group_3, SA_Partial_Delivery_Per_Item, CO_Dunn_Procedure, SA_Max_Partial_Deliveries_1, SA_Switch_Off_Rounding, SA_Relevant_For_POD, SA_Rebate, SA_Price_Determin, SA_Complete_Delivery_Reqd_By_Law, SA_Switch_Off_Rounding, SA_Relevant_For_POD, SA_Rebate, SA_Price_Determin, SA_Complete_Delivery_Reqd_By_Law, RE_CO_Sort_Key, RE_CO_Cash_Mgmt, RE_CO_Payment_History_Record, RE_CO_Bank_Statement, RE_SA_Sales_Org, RE_SA_Partial_Delivery_Per_Item, RE_SA_Max_Partial_Deliveries_1, RE_SA_Order_Combination, RE_SA_Customer_Group_3, RE_CO_Dunn_Procedure, RE_SA_Switch_Off_Rounding, RE_SA_Relevant_For_POD, RE_SA_Rebate, RE_SA_Price_Determin, RE_SA_Complete_Delivery_Reqd_By_Law);
            SetForeColor(Color.Orange, RE_BA_Account_Group_L, BA_Industry_L, RE_BA_Industry_L,SA_Delivering_Plant_L, RE_SA_Delivering_Plant_L, SA_Distribution_Channel_L, RE_SA_Distribution_Channel_L,  CO_Company_L, RE_CO_Company_L, CO_Sort_Key_L,  CO_Cash_Mgmt_L, CO_Payment_History_Record_L, CO_Bank_Statement_L, SA_Sales_Org_L, SA_Order_Combination_L,  SA_Departing_Country_L, SA_Customer_Group_3_L, SA_Partial_Delivery_Per_Item_L, CO_Dunn_Procedure_L, SA_Max_Partial_Deliveries_1_L, SA_Switch_Off_Rounding_L, SA_Relevant_For_POD_L, SA_Rebate_L, SA_Price_Determin_L, SA_Complete_Delivery_Reqd_By_Law_L, SA_Switch_Off_Rounding_L, SA_Relevant_For_POD_L, SA_Rebate_L, SA_Price_Determin_L, SA_Complete_Delivery_Reqd_By_Law_L, RE_CO_Sort_Key_L, RE_CO_Cash_Mgmt_L, RE_CO_Payment_History_Record_L, RE_CO_Bank_Statement_L, RE_SA_Sales_Org_L, RE_SA_Partial_Delivery_Per_Item_L, RE_SA_Max_Partial_Deliveries_1_L, RE_SA_Order_Combination_L,  RE_SA_Departing_Country_L, RE_SA_Customer_Group_3_L, RE_CO_Dunn_Procedure_L, RE_SA_Switch_Off_Rounding_L, RE_SA_Relevant_For_POD_L, RE_SA_Rebate_L, RE_SA_Price_Determin_L, RE_SA_Complete_Delivery_Reqd_By_Law_L);
        }
        #endregion

        #region 方法 InitDropdownList
        private void InitDropDownList()
        {
            if (!IsLoaded)
            {
                BA_Account_Group.Items.Clear();
                BA_Account_Group.Items.Add(new ListItem("", ""));
                IList<m_TW_Account_Group> hys = (m_TW_Account_Group.status == 1).List<m_TW_Account_Group>();
                foreach (m_TW_Account_Group HY in hys)
                {
                    BA_Account_Group.Items.Add(new ListItem(HY.Account_Group, HY.Account_Group));
                }

                BA_Region.Items.Clear();
                RE_BA_Region.Items.Clear();
                BA_Region.Items.Add(new ListItem("", ""));
                RE_BA_Region.Items.Add(new ListItem("", ""));
                IList<m_TW_Region> h1 = (m_TW_Region.status == 1).List<m_TW_Region>();
                foreach (m_TW_Region HY in h1)
                {
                    BA_Region.Items.Add(new ListItem(HY.TW_Region, HY.TW_Region));
                    RE_BA_Region.Items.Add(new ListItem(HY.TW_Region, HY.TW_Region));
                }


                BA_Bill_City_Code.Items.Clear();
                BA_City_Code.Items.Clear();
                RE_BA_City_Code.Items.Clear();
                BA_Bill_City_Code.Items.Add(new ListItem("", ""));
                BA_City_Code.Items.Add(new ListItem("", ""));
                RE_BA_City_Code.Items.Add(new ListItem("", ""));
                IList<m_TW_City_Code> h3 = (m_TW_City_Code.status == 1).List<m_TW_City_Code>();
                foreach (m_TW_City_Code HY in h3)
                {
                    BA_Bill_City_Code.Items.Add(new ListItem(HY.City_Code, HY.City_Code));
                    BA_City_Code.Items.Add(new ListItem(HY.City_Code, HY.City_Code));
                    RE_BA_City_Code.Items.Add(new ListItem(HY.City_Code, HY.City_Code));
                }


                //BA_Industry.Items.Clear();
                //RE_BA_Industry.Items.Clear();
                //BA_Industry.Items.Add(new ListItem("", ""));
                //RE_BA_Industry.Items.Add(new ListItem("", ""));
                //IList<m_TW_Industry_Global> h4 = (m_TW_Industry_Global.status == 1).List<m_TW_Industry_Global>();
                //foreach (m_TW_Industry_Global HY in h4)
                //{
                //    BA_Industry.Items.Add(new ListItem(HY.TW_Industry_Global, HY.TW_Industry_Global));
                //    RE_BA_Industry.Items.Add(new ListItem(HY.TW_Industry_Global, HY.TW_Industry_Global));
                //}

                BA_Industry1.Items.Clear();
                RE_BA_Industry1.Items.Clear();
                BA_Industry1.Items.Add(new ListItem("", ""));
                RE_BA_Industry1.Items.Add(new ListItem("", ""));
                IList<m_TW_Industry_Code1_Local> h5 = (m_TW_Industry_Code1_Local.status == 1).List<m_TW_Industry_Code1_Local>();
                foreach (m_TW_Industry_Code1_Local HY in h5)
                {
                    BA_Industry1.Items.Add(new ListItem(HY.Industry_Code1_Local, HY.Industry_Code1_Local));
                    RE_BA_Industry1.Items.Add(new ListItem(HY.Industry_Code1_Local, HY.Industry_Code1_Local));
                }


                //BA_Industry_Code3.Items.Clear();
                //RE_BA_Industry_Code3.Items.Clear();
                //BA_Industry_Code3.Items.Add(new ListItem("", ""));
                //RE_BA_Industry_Code3.Items.Add(new ListItem("", ""));
                //IList<m_TW_Industry_Code_3_Corp> h6 = (m_TW_Industry_Code_3_Corp.status == 1).List<m_TW_Industry_Code_3_Corp>();
                //foreach (m_TW_Industry_Code_3_Corp HY in h6)
                //{
                //    BA_Industry_Code3.Items.Add(new ListItem(HY.Industry_Code_3_Corp, HY.Industry_Code_3_Corp));
                //    RE_BA_Industry_Code3.Items.Add(new ListItem(HY.Industry_Code_3_Corp, HY.Industry_Code_3_Corp));
                //}


                CO_Recon_Account.Items.Clear();
                RE_CO_Recon_Account.Items.Clear();
                CO_Recon_Account.Items.Add(new ListItem("", ""));
                RE_CO_Recon_Account.Items.Add(new ListItem("", ""));
                IList<m_TW_CO_Recon_Account> h7 = (m_TW_CO_Recon_Account.status == 1).List<m_TW_CO_Recon_Account>();
                foreach (m_TW_CO_Recon_Account HY in h7)
                {
                    CO_Recon_Account.Items.Add(new ListItem(HY.CO_Recon_Account, HY.CO_Recon_Account));
                    RE_CO_Recon_Account.Items.Add(new ListItem(HY.CO_Recon_Account, HY.CO_Recon_Account));
                }


                CO_Payment_Terms.Items.Clear();
                RE_CO_Payment_Terms.Items.Clear();
                CO_Payment_Terms.Items.Add(new ListItem("", ""));
                RE_CO_Payment_Terms.Items.Add(new ListItem("", ""));
                IList<m_TW_Payment_Terms> h8 = (m_TW_Payment_Terms.status == 1).List<m_TW_Payment_Terms>();
                foreach (m_TW_Payment_Terms HY in h8)
                {
                    CO_Payment_Terms.Items.Add(new ListItem(HY.Payment_Terms, HY.Payment_Terms));
                    RE_CO_Payment_Terms.Items.Add(new ListItem(HY.Payment_Terms, HY.Payment_Terms));
                }


                CO_Payment_Methods.Items.Clear();
                RE_CO_Payment_Methods.Items.Clear();
                CO_Payment_Methods.Items.Add(new ListItem("", ""));
                RE_CO_Payment_Methods.Items.Add(new ListItem("", ""));
                IList<m_TW_Payment_Methods> h9 = (m_TW_Payment_Methods.status == 1).List<m_TW_Payment_Methods>();
                foreach (m_TW_Payment_Methods HY in h9)
                {
                    CO_Payment_Methods.Items.Add(new ListItem(HY.Payment_Methods, HY.Payment_Methods));
                    RE_CO_Payment_Methods.Items.Add(new ListItem(HY.Payment_Methods, HY.Payment_Methods));
                }


                SA_Sales_Office.Items.Clear();
                RE_SA_Sales_Office.Items.Clear();
                SA_Sales_Office.Items.Add(new ListItem("", ""));
                RE_SA_Sales_Office.Items.Add(new ListItem("", ""));
                IList<m_TW_Sales_Office> h10 = (m_TW_Sales_Office.status == 1).List<m_TW_Sales_Office>();
                foreach (m_TW_Sales_Office HY in h10)
                {
                    SA_Sales_Office.Items.Add(new ListItem(HY.Sales_Office, HY.Sales_Office));
                    RE_SA_Sales_Office.Items.Add(new ListItem(HY.Sales_Office, HY.Sales_Office));
                   
                }


             

                BA_Cust_Pric.Items.Clear();
                RE_BA_Cust_Pric.Items.Clear();
                BA_Cust_Pric.Items.Add(new ListItem("", ""));
                RE_BA_Cust_Pric.Items.Add(new ListItem("", ""));
                IList<m_TW_Cust_Pric_Proc> h12 = (m_TW_Cust_Pric_Proc.status == 1).List<m_TW_Cust_Pric_Proc>();
                foreach (m_TW_Cust_Pric_Proc HY in h12)
                {
                    BA_Cust_Pric.Items.Add(new ListItem(HY.Cust_Pric_Proc, HY.Cust_Pric_Proc));
                    RE_BA_Cust_Pric.Items.Add(new ListItem(HY.Cust_Pric_Proc, HY.Cust_Pric_Proc));
                }


                SA_Delivery_Priority.Items.Clear();
                RE_SA_Delivery_Priority.Items.Clear();
                SA_Delivery_Priority.Items.Add(new ListItem("", ""));
                RE_SA_Delivery_Priority.Items.Add(new ListItem("", ""));
                IList<m_TW_Delivery_Priority> h13 = (m_TW_Delivery_Priority.status == 1).List<m_TW_Delivery_Priority>();
                foreach (m_TW_Delivery_Priority HY in h13)
                {
                    SA_Delivery_Priority.Items.Add(new ListItem(HY.Delivery_Priority, HY.Delivery_Priority));
                    RE_SA_Delivery_Priority.Items.Add(new ListItem(HY.Delivery_Priority, HY.Delivery_Priority));
                }


                SA_Shipping_Condition.Items.Clear();
                RE_SA_Shipping_Condition.Items.Clear();
                SA_Shipping_Condition.Items.Add(new ListItem("", ""));
                IList<m_TW_Shipping_Conditions> h14 = (m_TW_Shipping_Conditions.status == 1).List<m_TW_Shipping_Conditions>();
                foreach (m_TW_Shipping_Conditions HY in h14)
                {
                    SA_Shipping_Condition.Items.Add(new ListItem(HY.Shipping_Conditions, HY.Shipping_Conditions));
                    RE_SA_Shipping_Condition.Items.Add(new ListItem(HY.Shipping_Conditions, HY.Shipping_Conditions));
                }


                SA_Itcoterms.Items.Clear();
                RE_SA_Itcoterms.Items.Clear();
                SA_Itcoterms.Items.Add(new ListItem("", ""));
                RE_SA_Itcoterms.Items.Add(new ListItem("", ""));
                IList<m_TW_Incoterms> h15 = (m_TW_Incoterms.status == 1).List<m_TW_Incoterms>();
                foreach (m_TW_Incoterms HY in h15)
                {
                    SA_Itcoterms.Items.Add(new ListItem(HY.Incoterms, HY.Incoterms));
                    RE_SA_Itcoterms.Items.Add(new ListItem(HY.Incoterms, HY.Incoterms));
                }



                SA_Acct_Assgmt_Group.Items.Clear();
                RE_SA_Acct_Assgmt_Group.Items.Clear();
                SA_Acct_Assgmt_Group.Items.Add(new ListItem("", ""));
                RE_SA_Acct_Assgmt_Group.Items.Add(new ListItem("", ""));
                IList<m_TW_Acct_Assgmt_Group> h16 = (m_TW_Acct_Assgmt_Group.status == 1).List<m_TW_Acct_Assgmt_Group>();
                foreach (m_TW_Acct_Assgmt_Group HY in h16)
                {
                    SA_Acct_Assgmt_Group.Items.Add(new ListItem(HY.Acct_Assgmt_Group, HY.Acct_Assgmt_Group));
                    RE_SA_Acct_Assgmt_Group.Items.Add(new ListItem(HY.Acct_Assgmt_Group, HY.Acct_Assgmt_Group));
                }


                Attributes1.Items.Clear();
                RE_Attributes1.Items.Clear();

                Attributes1.Items.Add(new ListItem("", ""));
                RE_Attributes1.Items.Add(new ListItem("", ""));
                IList<m_TW_Attributes1> h17 = (m_TW_Attributes1.status == 1).List<m_TW_Attributes1>();
                foreach (m_TW_Attributes1 HY in h17)
                {
                    Attributes1.Items.Add(new ListItem(HY.TW_Attributes1, HY.TW_Attributes1));
                    RE_Attributes1.Items.Add(new ListItem(HY.TW_Attributes1, HY.TW_Attributes1));
                }


                Attributes2.Items.Clear();
                RE_Attributes2.Items.Clear();
                Attributes2.Items.Add(new ListItem("", ""));
                RE_Attributes2.Items.Add(new ListItem("", ""));
                IList<m_TW_Attributes2> h18 = (m_TW_Attributes2.status == 1).List<m_TW_Attributes2>();
                foreach (m_TW_Attributes2 HY in h18)
                {
                    Attributes2.Items.Add(new ListItem(HY.TW_Attributes2, HY.TW_Attributes2));
                    RE_Attributes2.Items.Add(new ListItem(HY.TW_Attributes2, HY.TW_Attributes2));
                }
                

                Attributes3.Items.Clear();
                RE_Attributes3.Items.Clear();
                Attributes3.Items.Add(new ListItem("", ""));
                RE_Attributes3.Items.Add(new ListItem("", ""));
                IList<m_TW_Attributes3> h19 = (m_TW_Attributes3.status == 1).List<m_TW_Attributes3>();
                foreach (m_TW_Attributes3 HY in h19)
                {
                    Attributes3.Items.Add(new ListItem(HY.TW_Attributes3, HY.TW_Attributes3));
                    RE_Attributes3.Items.Add(new ListItem(HY.TW_Attributes3, HY.TW_Attributes3));
                }

 
                Attributes4.Items.Clear();
                RE_Attributes4.Items.Clear();
                Attributes4.Items.Add(new ListItem("", ""));
                RE_Attributes4.Items.Add(new ListItem("", ""));
                IList<m_TW_Attributes4> h20 = (m_TW_Attributes4.status == 1).List<m_TW_Attributes4>();
                foreach (m_TW_Attributes4 HY in h20)
                {
                    Attributes4.Items.Add(new ListItem(HY.TW_Attributes4, HY.TW_Attributes4));
                    RE_Attributes4.Items.Add(new ListItem(HY.TW_Attributes4, HY.TW_Attributes4));
                }

                
                Attributes5.Items.Clear();
                RE_Attributes5.Items.Clear();
                Attributes5.Items.Add(new ListItem("", ""));
                RE_Attributes5.Items.Add(new ListItem("", ""));
                IList<m_TW_Attributes5> h21 = (m_TW_Attributes5.status == 1).List<m_TW_Attributes5>();
                foreach (m_TW_Attributes5 HY in h21)
                {
                    
                    Attributes5.Items.Add(new ListItem(HY.TW_Attributes5, HY.TW_Attributes5));
                    RE_Attributes5.Items.Add(new ListItem(HY.TW_Attributes5, HY.TW_Attributes5));
                }


                //Attributes6.Items.Clear();
                //RE_Attributes6.Items.Clear();
                //Attributes6.Items.Add(new ListItem("", ""));
                //RE_Attributes6.Items.Add(new ListItem("", ""));
                //IList<m_TW_Attributes6> h25 = (m_TW_Attributes6.status == 1).List<m_TW_Attributes6>();
                //foreach (m_TW_Attributes6 HY in h25)
                //{

                //    Attributes6.Items.Add(new ListItem(HY.Attributes6, HY.Attributes6));
                //    RE_Attributes6.Items.Add(new ListItem(HY.Attributes6, HY.Attributes6));
                //}

                Attributes7.Items.Clear();
                RE_Attributes7.Items.Clear();
                Attributes7.Items.Add(new ListItem("", ""));
                RE_Attributes7.Items.Add(new ListItem("", ""));
                IList<m_TW_Attributes7> h26 = (m_TW_Attributes7.status == 1).List<m_TW_Attributes7>();
                foreach (m_TW_Attributes7 HY in h26)
                {

                    Attributes7.Items.Add(new ListItem(HY.Attributes7, HY.Attributes7));
                    RE_Attributes7.Items.Add(new ListItem(HY.Attributes7, HY.Attributes7));
                }

                BA_Bank_Country.Items.Clear();
                RE_BA_Bank_Country.Items.Clear();
                BA_Bank_Country.Items.Add(new ListItem("", ""));
                RE_BA_Bank_Country.Items.Add(new ListItem("", ""));
                IList<m_TW_Bank_Country> h22 = (m_TW_Bank_Country.status == 1).List<m_TW_Bank_Country>();
                foreach (m_TW_Bank_Country HY in h22)
                {

                    BA_Bank_Country.Items.Add(new ListItem(HY.Bank_Country, HY.Bank_Country));
                    RE_BA_Bank_Country.Items.Add(new ListItem(HY.Bank_Country, HY.Bank_Country));
                }


                //BA_Sales_Employee.Items.Clear();
                //RE_BA_Sales_Employee.Items.Clear();
                //BA_Sales_Employee.Items.Add(new ListItem("", ""));
                //RE_BA_Sales_Employee.Items.Add(new ListItem("", ""));
                //IList<m_TW_Employee> h23 = (m_TW_Employee.status == 1).List<m_TW_Employee>();
                //foreach (m_TW_Employee HY in h23)
                //{

                //    BA_Sales_Employee.Items.Add(new ListItem(HY.Employee, HY.Employee));
                //    RE_BA_Sales_Employee.Items.Add(new ListItem(HY.Employee, HY.Employee));
                //}


                BA_APO_Group.Items.Clear();
                RE_BA_APO_Group.Items.Clear();
                BA_APO_Group.Items.Add(new ListItem("", ""));
                RE_BA_APO_Group.Items.Add(new ListItem("", ""));
                IList<m_TW_Customer_Group_PKG> h24 = (m_TW_Customer_Group_PKG.status == 1).List<m_TW_Customer_Group_PKG>();
                foreach (m_TW_Customer_Group_PKG HY in h24)
                {

                    BA_APO_Group.Items.Add(new ListItem(HY.APO_Customer, HY.APO_Customer));
                    RE_BA_APO_Group.Items.Add(new ListItem(HY.APO_Customer, HY.APO_Customer));
                 
                }

                SA_Currency.Items.Clear();
                RE_SA_Currency.Items.Clear();
                SA_Currency.Items.Add(new ListItem("", ""));
                RE_SA_Currency.Items.Add(new ListItem("", ""));
                IList<m_TW_Currency> h25 = (m_TW_Currency.status == 1).List<m_TW_Currency>();
                foreach (m_TW_Currency HY in h25)
                {

                    SA_Currency.Items.Add(new ListItem(HY.Currency, HY.Currency));
                    RE_SA_Currency.Items.Add(new ListItem(HY.Currency, HY.Currency));

                }

                BA_Instruction_Key.Items.Clear();
                RE_BA_Instruction_Key.Items.Clear();
                BA_Instruction_Key.Items.Add(new ListItem("", ""));
                RE_BA_Instruction_Key.Items.Add(new ListItem("", ""));
                IList<m_TW_Instruction_Key> h27 = (m_TW_Instruction_Key.status == 1).List<m_TW_Instruction_Key>();
                foreach (m_TW_Instruction_Key HY in h27)
                {

                    BA_Instruction_Key.Items.Add(new ListItem(HY.Instruction_Key, HY.Instruction_Key));
                    RE_BA_Instruction_Key.Items.Add(new ListItem(HY.Instruction_Key, HY.Instruction_Key));

                }

                BA_Country.Items.Clear();
                RE_BA_Country.Items.Clear();
                BA_Country.Items.Add(new ListItem("", ""));
                RE_BA_Country.Items.Add(new ListItem("", ""));
                IList<m_TW_Country> h28 = (m_TW_Country.status == 1).List<m_TW_Country>();
                foreach (m_TW_Country HY in h28)
                {

                    BA_Country.Items.Add(new ListItem(HY.Country, HY.Country));
                    RE_BA_Country.Items.Add(new ListItem(HY.Country, HY.Country));

                }

                BA_Indirect_Transportation_Zone.Items.Clear();
                BA_Transportation_Zone.Items.Clear();
                RE_BA_Transportation_Zone.Items.Clear();
                BA_Indirect_Transportation_Zone.Items.Add(new ListItem("", ""));
                BA_Transportation_Zone.Items.Add(new ListItem("", ""));
                RE_BA_Transportation_Zone.Items.Add(new ListItem("", ""));
                IList<m_TW_Transportation_Zone> h29 = (m_TW_Transportation_Zone.status == 1).List<m_TW_Transportation_Zone>();
                foreach (m_TW_Transportation_Zone HY in h29)
                {
                    BA_Indirect_Transportation_Zone.Items.Add(new ListItem(HY.Transportation_Zone, HY.Transportation_Zone));
                    BA_Transportation_Zone.Items.Add(new ListItem(HY.Transportation_Zone, HY.Transportation_Zone));
                    RE_BA_Transportation_Zone.Items.Add(new ListItem(HY.Transportation_Zone, HY.Transportation_Zone));
                }

                IsLoaded = true;
            }
        }
        #endregion

        #region 方法 数据验证
        private List<string> DataValidation()
        {
            List<string> vald_s = new List<string>();
            List<string> vald_s_2 = new List<string>();
            List<string> vald_s_3 = new List<string>();
            List<string> vald_s_4 = new List<string>();
            List<string> vald_s_5 = new List<string>();
            List<Regular> regs = new List<Regular>();
            
            
            
            #region VD
            if (VD.Checked && Actions.SelectedValue == "1")
            {
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Type.SelectedValue, "Type 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Account_Group.SelectedValue, "Account Group 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Customer_Name_In_ZH.Text, "Name 1 必填"));
                //regs.Add(new Regular(RegularExp.NotEmpty, BA_Region.SelectedValue, "Region(縣市) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Existed_Sold_To_Code_City.Text, "City(鄉鎮市) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Existed_Sold_To_Code_Address.Text, "Street/House No(詳細地址) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Transportation_Zone.SelectedValue, "Transportation Zone 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Indirect_Transportation_Zone.SelectedValue, "Transportation Zone 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Country.SelectedValue, "Country 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Language.SelectedValue, "Language 必填"));
               // regs.Add(new Regular(RegularExp.NotEmpty, BA_City_Code.SelectedValue, "City code(城市代碼)) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, CO_Recon_Account.SelectedValue, "Recon. Account(統馭科目)) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, CO_Payment_Terms.SelectedValue, "Payment Terms(付款條件) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, CO_Payment_Methods.SelectedValue, "Payment Methods(支付方法) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_Currency.SelectedValue, "Currency(幣種): 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_Delivery_Priority.SelectedValue, "Delivery Priority(交貨優先級) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_Shipping_Condition.SelectedValue, "Shipping Conditions(運輸條件) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Cust_Pric.SelectedValue, "Cust.pric.proc. 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_Acct_Assgmt_Group.SelectedValue, "Acct assgmt group 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_Itcoterms.SelectedValue, "Incoterms 必填"));
                if (!SA_Customer_Division_K4.Checked && !SA_Customer_Division_K5.Checked )
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", "1.Domestic-K4 或 2.Export-K5 至少需要填写 1 个"));
                }
              
              
             
            }

            if (VD.Checked && Actions.SelectedValue != "1")
            {
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Type.SelectedValue, "Type 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Existed_Sold_To_Code.Text, "Existed Customer Code 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Customer_Name_In_ZH.Text, "Name 1 必填")); 
                          
            }

            vald_s = Validation(regs);
            if (vald_s.Count > 0)
            {
                vald_s.Insert(0, "<font color='#0000FF'><b>Customer</b></font>");
            }
            #endregion

           

            #region SA2
            regs.Clear();
            if (SA2.Checked && Actions.SelectedValue == "1")
            {

               // regs.Add(new Regular(RegularExp.NotEmpty, RE_BA_Account_Group.Text, "Bank account(銀行帳號) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_BA_Type.SelectedValue, "Type 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_BA_SoldTo_Code.Text, "Sold to Code 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_BA_Customer_Name_In_ZH.Text, "Name 1 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_BA_Existed_Sold_To_Code_City.Text, "City(鄉鎮市) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_BA_Existed_Sold_To_Code_Address.Text, "Street/House No(詳細地址) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_BA_Transportation_Zone.SelectedValue, "Transportation Zone 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_BA_Country.SelectedValue, "Country 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_BA_Language.SelectedValue, "Language 必填"));
                //regs.Add(new Regular(RegularExp.NotEmpty, RE_BA_Region.SelectedValue, "Region(縣市) 必填"));
               // regs.Add(new Regular(RegularExp.NotEmpty, RE_BA_Industry.SelectedValue, "Industry(Global) 必填"));
                //regs.Add(new Regular(RegularExp.NotEmpty, RE_BA_City_Code.SelectedValue, "City code(城市代碼) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_CO_Recon_Account.SelectedValue, "Recon. Account(統馭科目) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_CO_Payment_Terms.SelectedValue, "Payment Terms(付款條件) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_CO_Payment_Methods.SelectedValue, "Payment Methods(支付方法) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_SA_Currency.SelectedValue, "Currency(幣種): 必填"));
               // regs.Add(new Regular(RegularExp.NotEmpty, RE_SA_Sales_Office.SelectedValue, "Sales Office(銷售區域) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_SA_Delivery_Priority.SelectedValue, "Delivery Priority(交貨優先級) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_SA_Shipping_Condition.SelectedValue, "Shipping Conditions(運輸條件) 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_BA_Cust_Pric.SelectedValue, "Cust.pric.proc. 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_SA_Acct_Assgmt_Group.SelectedValue, "Acct assgmt group 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_SA_Itcoterms.SelectedValue, "Incoterms 必填"));
                if (!RE_SA_Customer_Division_K4.Checked && !RE_SA_Customer_Division_K5.Checked)
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", "1.Domestic-K4 或 2.Export-K5 至少需要填写 1 个"));
                } 
            }

            if (SA2.Checked && Actions.SelectedValue != "1")
            {
                regs.Add(new Regular(RegularExp.NotEmpty, RE_BA_Type.SelectedValue, "Type 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_BA_Existed_Sold_To_Code.Text, "Existed Rebate Code 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, RE_BA_Customer_Name_In_ZH.Text, "Name 1 必填"));
               
            }

            vald_s_3 = Validation(regs);
            if (vald_s_3.Count > 0)
            {
                vald_s_3.Insert(0, "<font color='#0000FF'><b>Payer for Rebate</b></font>");
                vald_s.AddRange(vald_s_3);
            }
            #endregion

      
           

            return vald_s;
            //return Validation(regs);
        }
        #endregion

        #region 方法 Others
        private string getFormCheckList(Anthem .CheckBoxList ck)
        {
            string t = "";
            for (int i = 0; i < ck.Items.Count; i++)
                if (ck.Items[i].Selected)
                    t += "," + ck.Items[i].Value;
                else
                    t += ",";
            return t;
        }
        private Anthem.CheckBoxList setCheckList(string t, Anthem .CheckBoxList ck)
        {
            try
            {
                string[] tt = t.Split(',');

                for (int i = 0; i <= tt.GetUpperBound(0); i++)
                {
                    for (int j = 0; j < ck.Items.Count; j++)
                    {
                        if (ck.Items[j].Value == tt[i].ToString())
                        { ck.Items[j].Selected = true; break; }
                    }
                }
            }
            catch { }
            return ck;
        }
        #endregion

        #region 方法 SetDropDownListValue
        private void SetDropDownListValue(Anthem.DropDownList drpT, object o)
        {
            try
            {
                if ((TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit) || drpT.Items.FindByValue(o.ToString()) != null)
                {
                    drpT.SelectedValue = o.ToString();
                    return;
                }

                drpT.Items.Add(new ListItem(o.ToString(), o.ToString()));
                drpT.SelectedIndex = 0;

            }
            catch (Exception)
            {
            }
        }
        #endregion

        #region 重载 OnLoadComplete
        protected override void OnLoadComplete(EventArgs e)
        {
            if (!IsLoaded && TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit)
            {
                Actions_SelectedIndexChanged(null, e);
            }

            base.OnLoadComplete(e);
        }
        #endregion      

        #region 表单中 Seach Term 1= Name1 ,Seach Term 2= BPCS Code
        protected void BA_Customer_Name_In_ZH_TextChanged(object sender, EventArgs e)
        {
            BA_Search_Term_1.Text=BA_Customer_Name_In_ZH.Text;
            BA_Acct_Holder.Text = BA_Customer_Name_In_ZH.Text;
        }
       

       
        protected void RE_BA_Customer_Name_In_ZH_TextChanged(object sender, EventArgs e)
        {
            RE_BA_Search_Term_1.Text = RE_BA_Customer_Name_In_ZH.Text;
            RE_BA_Acct_Holder.Text = RE_BA_Customer_Name_In_ZH.Text;
        }
       

        
        protected void BA_BPCS_Code_TextChanged(object sender, EventArgs e)
        {
            BA_Search_Term_2.Text = BA_BPCS_Code.Text;
            //BA_Bill_Search_Term2.Text = BA_BPCS_Code.Text;
            CO_BPCS.Text = BA_BPCS_Code.Text;
        }

      
      
        protected void RE_BA_BPCS_Code_TextChanged(object sender, EventArgs e)
        {
            RE_BA_Search_Term_2.Text = RE_BA_BPCS_Code.Text;
            RE_CO_BPCS.Text = RE_BA_BPCS_Code.Text;
        }

       

        
        protected void Internat_Name_TextChanged(object sender, EventArgs e)
        {
            Internat_Seach_Term.Text = Internat_Name.Text;
        }
        

        protected void BA_Bill_Name1_TextChanged(object sender, EventArgs e)
        {
            BA_Bill_Search_Term1.Text = BA_Bill_Name1.Text;
        }

        protected void BA_Indirect_Name1_TextChanged(object sender, EventArgs e)
        {
            BA_Indirect_Search_Term1.Text = BA_Indirect_Name1.Text;
        }

        protected void BA_Old_BPCS_Indirect_TextChanged(object sender, EventArgs e)
        {
            BA_Indirect_Search_Term2.Text = BA_Old_BPCS_Indirect.Text;
        }
        #endregion

        #region City Code带出County Code
        protected void BA_Bill_City_Code_SelectedIndexChanged(object sender, EventArgs e)
        {
            BA_Bill_County_Code.Text = "";
            IList<m_TW_City_Code> bh2 = (m_TW_City_Code.status == 1 & (m_TW_City_Code.city_Code == BA_Bill_City_Code.SelectedValue
             | m_TW_City_Code.city_Code == "")).List<m_TW_City_Code>();
            foreach (m_TW_City_Code BH in bh2)
            {

                BA_Bill_County_Code.Text = BH.County_Code;

            }
        }

        protected void BA_City_Code_SelectedIndexChanged(object sender, EventArgs e)
        {
            BA_County_Code.Text = "";
            IList<m_TW_City_Code> bh2 = (m_TW_City_Code.status == 1 & (m_TW_City_Code.city_Code == BA_City_Code.SelectedValue
             | m_TW_City_Code.city_Code == "")).List<m_TW_City_Code>();
            foreach (m_TW_City_Code BH in bh2)
            {

                BA_County_Code.Text = BH.County_Code;

            }
        }

       
        protected void RE_BA_City_Code_SelectedIndexChanged(object sender, EventArgs e)
        {
            RE_BA_County_Code.Text = "";
            IList<m_TW_City_Code> bh4 = (m_TW_City_Code.status == 1 & (m_TW_City_Code.city_Code == RE_BA_City_Code.SelectedValue
             | m_TW_City_Code.city_Code == "")).List<m_TW_City_Code>();
            foreach (m_TW_City_Code BH in bh4)
            {

                RE_BA_County_Code.Text = BH.County_Code;

            }
        }
        #endregion

        #region Terms of Payment= Payment Terms
        protected void CO_Payment_Terms_SelectedIndexChanged(object sender, EventArgs e)
        {
            SA_Terms_Of_Payment.Text = CO_Payment_Terms.Text;
        }

        protected void RE_CO_Payment_Terms_SelectedIndexChanged(object sender, EventArgs e)
        {
            RE_SA_Terms_Of_Payment.Text = RE_CO_Payment_Terms.Text;
        }
        #endregion

        #region sales person
        protected void RE_BA_Sales_Employee_Code_TextChanged(object sender, EventArgs e)
        {
            RE_SA_Sales_Code.Text = RE_BA_Sales_Employee_Code.Text;
        }

        protected void BA_Sales_Employee_Code_TextChanged(object sender, EventArgs e)
        {
            SA_Sales_Code.Text = BA_Sales_Employee_Code.Text;
        }
        #endregion

        #region Region
        protected void RE_BA_Region_SelectedIndexChanged(object sender, EventArgs e)
        {
            RE_Attributes9.Text = RE_BA_Region.Text;
        }

        protected void BA_Region_SelectedIndexChanged(object sender, EventArgs e)
        {
            Attributes9.Text = BA_Region.Text;
        }
        #endregion

        protected void SA_Customer_Division_K4_CheckedChanged(object sender, EventArgs e)
        {
            if (SA_Customer_Division_K4.Checked)
            {
                SA_Customer_Division_K5.Checked = false;
                SA_Tax_Classification.Text = "1";
            }
            else if (!SA_Customer_Division_K4.Checked || !SA_Customer_Division_K4.Checked)
            {
                SA_Tax_Classification.Text = "";
            }
        }



        protected void SA_Customer_Division_K5_CheckedChanged(object sender, EventArgs e)
        {
            if (SA_Customer_Division_K5.Checked)
            {
                SA_Customer_Division_K4.Checked = false;
                SA_Tax_Classification.Text = "0";
            }
            else if (!SA_Customer_Division_K4.Checked || !SA_Customer_Division_K4.Checked)
            {
                SA_Tax_Classification.Text = "";
            }
        }

        protected void RE_SA_Customer_Division_K4_CheckedChanged(object sender, EventArgs e)
        {
            if (RE_SA_Customer_Division_K4.Checked)
            {
                RE_SA_Customer_Division_K5.Checked = false;
                RE_SA_Tax_Classification.Text = "1";
            }
            else if (!RE_SA_Customer_Division_K4.Checked || !RE_SA_Customer_Division_K4.Checked) 
            {
                RE_SA_Tax_Classification.Text = "";
            }
        }

        protected void RE_SA_Customer_Division_K5_CheckedChanged(object sender, EventArgs e)
        {
            if (RE_SA_Customer_Division_K5.Checked)
            {
                RE_SA_Customer_Division_K4.Checked = false;
                RE_SA_Tax_Classification.Text = "0";
            }
            else if (!RE_SA_Customer_Division_K4.Checked || !RE_SA_Customer_Division_K4.Checked)
            {
                RE_SA_Tax_Classification.Text = "";
            }
        }

      

      
      

      

      
        

       
        

       

      
    }
}